(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define("Phaser", [], factory); else if(typeof exports === 'object') exports["Phaser"] = factory(); else root["Phaser"] = factory(); })(this, () => { return /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ 50792: /***/ ((module) => { "use strict"; var has = Object.prototype.hasOwnProperty , prefix = '~'; /** * Constructor to create a storage for our `EE` objects. * An `Events` instance is a plain object whose properties are event names. * * @constructor * @private */ function Events() {} // // We try to not inherit from `Object.prototype`. In some engines creating an // instance in this way is faster than calling `Object.create(null)` directly. // If `Object.create(null)` is not supported we prefix the event names with a // character to make sure that the built-in object properties are not // overridden or used as an attack vector. // if (Object.create) { Events.prototype = Object.create(null); // // This hack is needed because the `__proto__` property is still inherited in // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5. // if (!new Events().__proto__) prefix = false; } /** * Representation of a single event listener. * * @param {Function} fn The listener function. * @param {*} context The context to invoke the listener with. * @param {Boolean} [once=false] Specify if the listener is a one-time listener. * @constructor * @private */ function EE(fn, context, once) { this.fn = fn; this.context = context; this.once = once || false; } /** * Add a listener for a given event. * * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. * @param {(String|Symbol)} event The event name. * @param {Function} fn The listener function. * @param {*} context The context to invoke the listener with. * @param {Boolean} once Specify if the listener is a one-time listener. * @returns {EventEmitter} * @private */ function addListener(emitter, event, fn, context, once) { if (typeof fn !== 'function') { throw new TypeError('The listener must be a function'); } var listener = new EE(fn, context || emitter, once) , evt = prefix ? prefix + event : event; if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++; else if (!emitter._events[evt].fn) emitter._events[evt].push(listener); else emitter._events[evt] = [emitter._events[evt], listener]; return emitter; } /** * Clear event by name. * * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. * @param {(String|Symbol)} evt The Event name. * @private */ function clearEvent(emitter, evt) { if (--emitter._eventsCount === 0) emitter._events = new Events(); else delete emitter._events[evt]; } /** * Minimal `EventEmitter` interface that is molded against the Node.js * `EventEmitter` interface. * * @constructor * @public */ function EventEmitter() { this._events = new Events(); this._eventsCount = 0; } /** * Return an array listing the events for which the emitter has registered * listeners. * * @returns {Array} * @public */ EventEmitter.prototype.eventNames = function eventNames() { var names = [] , events , name; if (this._eventsCount === 0) return names; for (name in (events = this._events)) { if (has.call(events, name)) names.push(prefix ? name.slice(1) : name); } if (Object.getOwnPropertySymbols) { return names.concat(Object.getOwnPropertySymbols(events)); } return names; }; /** * Return the listeners registered for a given event. * * @param {(String|Symbol)} event The event name. * @returns {Array} The registered listeners. * @public */ EventEmitter.prototype.listeners = function listeners(event) { var evt = prefix ? prefix + event : event , handlers = this._events[evt]; if (!handlers) return []; if (handlers.fn) return [handlers.fn]; for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) { ee[i] = handlers[i].fn; } return ee; }; /** * Return the number of listeners listening to a given event. * * @param {(String|Symbol)} event The event name. * @returns {Number} The number of listeners. * @public */ EventEmitter.prototype.listenerCount = function listenerCount(event) { var evt = prefix ? prefix + event : event , listeners = this._events[evt]; if (!listeners) return 0; if (listeners.fn) return 1; return listeners.length; }; /** * Calls each of the listeners registered for a given event. * * @param {(String|Symbol)} event The event name. * @returns {Boolean} `true` if the event had listeners, else `false`. * @public */ EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { var evt = prefix ? prefix + event : event; if (!this._events[evt]) return false; var listeners = this._events[evt] , len = arguments.length , args , i; if (listeners.fn) { if (listeners.once) this.removeListener(event, listeners.fn, undefined, true); switch (len) { case 1: return listeners.fn.call(listeners.context), true; case 2: return listeners.fn.call(listeners.context, a1), true; case 3: return listeners.fn.call(listeners.context, a1, a2), true; case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true; case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; } for (i = 1, args = new Array(len -1); i < len; i++) { args[i - 1] = arguments[i]; } listeners.fn.apply(listeners.context, args); } else { var length = listeners.length , j; for (i = 0; i < length; i++) { if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true); switch (len) { case 1: listeners[i].fn.call(listeners[i].context); break; case 2: listeners[i].fn.call(listeners[i].context, a1); break; case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break; case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break; default: if (!args) for (j = 1, args = new Array(len -1); j < len; j++) { args[j - 1] = arguments[j]; } listeners[i].fn.apply(listeners[i].context, args); } } } return true; }; /** * Add a listener for a given event. * * @param {(String|Symbol)} event The event name. * @param {Function} fn The listener function. * @param {*} [context=this] The context to invoke the listener with. * @returns {EventEmitter} `this`. * @public */ EventEmitter.prototype.on = function on(event, fn, context) { return addListener(this, event, fn, context, false); }; /** * Add a one-time listener for a given event. * * @param {(String|Symbol)} event The event name. * @param {Function} fn The listener function. * @param {*} [context=this] The context to invoke the listener with. * @returns {EventEmitter} `this`. * @public */ EventEmitter.prototype.once = function once(event, fn, context) { return addListener(this, event, fn, context, true); }; /** * Remove the listeners of a given event. * * @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. * @returns {EventEmitter} `this`. * @public */ EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) { var evt = prefix ? prefix + event : event; if (!this._events[evt]) return this; if (!fn) { clearEvent(this, evt); return this; } var listeners = this._events[evt]; if (listeners.fn) { if ( listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context) ) { clearEvent(this, evt); } } else { for (var i = 0, events = [], length = listeners.length; i < length; i++) { if ( listeners[i].fn !== fn || (once && !listeners[i].once) || (context && listeners[i].context !== context) ) { events.push(listeners[i]); } } // // Reset the array, or remove it completely if we have no more listeners. // if (events.length) this._events[evt] = events.length === 1 ? events[0] : events; else clearEvent(this, evt); } return this; }; /** * Remove all listeners, or those of the specified event. * * @param {(String|Symbol)} [event] The event name. * @returns {EventEmitter} `this`. * @public */ EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) { var evt; if (event) { evt = prefix ? prefix + event : event; if (this._events[evt]) clearEvent(this, evt); } else { this._events = new Events(); this._eventsCount = 0; } return this; }; // // Alias methods names because people roll like that. // EventEmitter.prototype.off = EventEmitter.prototype.removeListener; EventEmitter.prototype.addListener = EventEmitter.prototype.on; // // Expose the prefix. // EventEmitter.prefixed = prefix; // // Allow `EventEmitter` to be imported as module namespace. // EventEmitter.EventEmitter = EventEmitter; // // Expose the module. // if (true) { module.exports = EventEmitter; } /***/ }), /***/ 11517: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author samme * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var QuickSet = __webpack_require__(38829); /** * Takes an array of Game Objects and aligns them next to each other. * * The alignment position is controlled by the `position` parameter, which should be one * of the Phaser.Display.Align constants, such as `Phaser.Display.Align.TOP_LEFT`, * `Phaser.Display.Align.TOP_CENTER`, etc. * * The first item isn't moved. The second item is aligned next to the first, * then the third next to the second, and so on. * * @function Phaser.Actions.AlignTo * @since 3.22.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {number} position - The position to align the items with. This is an align constant, such as `Phaser.Display.Align.LEFT_CENTER`. * @param {number} [offsetX=0] - Optional horizontal offset from the position. * @param {number} [offsetY=0] - Optional vertical offset from the position. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. */ var AlignTo = function (items, position, offsetX, offsetY) { var target = items[0]; for (var i = 1; i < items.length; i++) { var item = items[i]; QuickSet(item, target, position, offsetX, offsetY); target = item; } return items; }; module.exports = AlignTo; /***/ }), /***/ 80318: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueInc = __webpack_require__(66979); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 60757: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * Takes an array of objects and passes each of them to the given callback. * * @function Phaser.Actions.Call * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {Phaser.Types.Actions.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|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 69927: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items] * * @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 {number} [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; /***/ }), /***/ 32265: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items] * * @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 {number} [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 = items.length - 1; i >= index; 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; /***/ }), /***/ 94420: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var AlignIn = __webpack_require__(11879); var CONST = __webpack_require__(60461); var GetFastValue = __webpack_require__(95540); var NOOP = __webpack_require__(29747); var Zone = __webpack_require__(41481); var tempZone = new Zone({ sys: { queueDepthSort: NOOP, events: { once: NOOP } } }, 0, 0, 1, 1).setOrigin(0, 0); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {Phaser.Types.Actions.GridAlignConfig} options - The GridAlign Configuration object. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. */ var GridAlign = function (items, options) { if (options === undefined) { options = {}; } var widthSet = options.hasOwnProperty('width'); var heightSet = options.hasOwnProperty('height'); 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 (widthSet && width === -1) { // We keep laying them out horizontally until we've done them all tempZone.x += cellWidth; } else if (heightSet && height === -1) { // We keep laying them out vertically until we've done them all tempZone.y += cellHeight; } else if (heightSet && !widthSet) { // We keep laying them out until we hit the column limit cy += cellHeight; tempZone.y += cellHeight; if (cy === h) { cy = 0; cx += cellWidth; tempZone.y = y; tempZone.x += cellWidth; if (cx === w) { // We've hit the column limit, so return, even if there are items left break; } } } 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; /***/ }), /***/ 41721: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueInc = __webpack_require__(66979); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 67285: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueInc = __webpack_require__(66979); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 9074: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueInc = __webpack_require__(66979); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 75222: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueInc = __webpack_require__(66979); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 22983: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Circle. * * If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.PlaceOnCircle * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 - The Circle to position the Game Objects on. * @param {number} [startAngle=0] - Optional angle to start position from, in radians. * @param {number} [endAngle=6.28] - Optional angle to stop position at, in radians. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; var cx = circle.x; var cy = circle.y; var radius = circle.radius; for (var i = 0; i < items.length; i++) { items[i].x = cx + (radius * Math.cos(angle)); items[i].y = cy + (radius * Math.sin(angle)); angle += angleStep; } return items; }; module.exports = PlaceOnCircle; /***/ }), /***/ 95253: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of an Ellipse. * * If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.PlaceOnEllipse * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 - The Ellipse to position the Game Objects on. * @param {number} [startAngle=0] - Optional angle to start position from, in radians. * @param {number} [endAngle=6.28] - Optional angle to stop position at, in radians. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 88505: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetPoints = __webpack_require__(15258); var GetEasedPoints = __webpack_require__(26708); /** * Positions an array of Game Objects on evenly spaced points of a Line. * If the ease parameter is supplied, it will space the points based on that easing function along the line. * * @function Phaser.Actions.PlaceOnLine * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 - The Line to position the Game Objects on. * @param {(string|function)} [ease] - An optional ease to use. This can be either a string from the EaseMap, or a custom function. * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ var PlaceOnLine = function (items, line, ease) { var points; if (ease) { points = GetEasedPoints(line, ease, items.length); } else { 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; /***/ }), /***/ 41346: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var MarchingAnts = __webpack_require__(14649); var RotateLeft = __webpack_require__(86003); var RotateRight = __webpack_require__(49498); /** * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a 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. * * @function Phaser.Actions.PlaceOnRectangle * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 to position the Game Objects on. * @param {number} [shift=0] - An optional positional offset. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 11575: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var BresenhamPoints = __webpack_require__(84993); /** * Takes an array of Game Objects and positions them on evenly spaced points around the edges of a Triangle. * * If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.PlaceOnTriangle * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 - The Triangle to position the Game Objects on. * @param {number} [stepRate=1] - An optional step rate, to increase or decrease the packing of the Game Objects on the lines. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 29953: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * Play an animation on all Game Objects in the array that have an Animation component. * * You can pass either an animation key, or an animation configuration object for more control over the playback. * * @function Phaser.Actions.PlayAnimation * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. * @param {boolean} [ignoreIfPlaying=false] - If this animation is already playing then ignore this call. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ var PlayAnimation = function (items, key, ignoreIfPlaying) { for (var i = 0; i < items.length; i++) { var gameObject = items[i]; if (gameObject.anims) { gameObject.anims.play(key, ignoreIfPlaying); } } return items; }; module.exports = PlayAnimation; /***/ }), /***/ 66979: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * 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. * * The optional `step` property is applied incrementally, multiplied by each item in the array. * * To use this with a Group: `PropertyValueInc(group.getChildren(), key, value, step)` * * @function Phaser.Actions.PropertyValueInc * @since 3.3.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. */ var PropertyValueInc = 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 = PropertyValueInc; /***/ }), /***/ 43967: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 88926: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Random = __webpack_require__(28176); /** * Takes an array of Game Objects and positions them at random locations within the Circle. * * If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.RandomCircle * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 - The Circle to position the Game Objects within. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 33286: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Random = __webpack_require__(24820); /** * Takes an array of Game Objects and positions them at random locations within the Ellipse. * * If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.RandomEllipse * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 - The Ellipse to position the Game Objects within. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 96000: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Random = __webpack_require__(65822); /** * Takes an array of Game Objects and positions them at random locations on the Line. * * If you wish to pass a `Phaser.GameObjects.Line` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.RandomLine * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 - The Line to position the Game Objects randomly on. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 28789: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Random = __webpack_require__(26597); /** * Takes an array of Game Objects and positions them at random locations within the Rectangle. * * @function Phaser.Actions.RandomRectangle * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 to position the Game Objects within. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 97154: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Random = __webpack_require__(90260); /** * Takes an array of Game Objects and positions them at random locations within the Triangle. * * If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.RandomTriangle * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 - The Triangle to position the Game Objects within. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 20510: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueInc = __webpack_require__(66979); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 91051: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var RotateAroundDistance = __webpack_require__(1163); var DistanceBetween = __webpack_require__(20339); /** * Rotates each item around the given point by the given angle. * * @function Phaser.Actions.RotateAround * @since 3.0.0 * @see Phaser.Math.RotateAroundDistance * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 76332: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var MathRotateAroundDistance = __webpack_require__(1163); /** * Rotates an array of Game Objects around a point by the given angle and distance. * * @function Phaser.Actions.RotateAroundDistance * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 61619: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueInc = __webpack_require__(66979); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 94868: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueInc = __webpack_require__(66979); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 `scaleY` amount, multiplied by the iteration counter. * @param {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 95532: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueInc = __webpack_require__(66979); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 8689: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueSet = __webpack_require__(43967); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 2645: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueSet = __webpack_require__(43967); /** * Takes an array of Game Objects, or any objects that have the public property `blendMode` * and then sets it to the given value. * * To use this with a Group: `SetBlendMode(group.getChildren(), value)` * * @function Phaser.Actions.SetBlendMode * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(Phaser.BlendModes|string|number)} value - The Blend Mode to be set. * @param {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 32372: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueSet = __webpack_require__(43967); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 85373: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * Passes all provided Game Objects to the Input Manager to enable them for input with identical areas and callbacks. * * @see {@link Phaser.GameObjects.GameObject#setInteractive} * * @function Phaser.Actions.SetHitArea * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. * @param {(Phaser.Types.Input.InputConfiguration|any)} [hitArea] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not given it will try to create a Rectangle based on the texture frame. * @param {Phaser.Types.Input.HitAreaCallback} [callback] - The callback that determines if the pointer is within the Hit Area shape or not. If you provide a shape you must also provide a callback. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 81583: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueSet = __webpack_require__(43967); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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); PropertyValueSet(items, 'originY', originY, stepY, index, direction); items.forEach(function (item) { item.updateDisplayOrigin(); }); return items; }; module.exports = SetOrigin; /***/ }), /***/ 79939: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueSet = __webpack_require__(43967); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 2699: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueSet = __webpack_require__(43967); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 98739: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueSet = __webpack_require__(43967); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 98476: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueSet = __webpack_require__(43967); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 6207: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueSet = __webpack_require__(43967); /** * Takes an array of Game Objects, or any objects that have the public properties `scrollFactorX` and `scrollFactorY` * 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: `SetScrollFactor(group.getChildren(), scrollFactorX, scrollFactorY, stepX, stepY)` * * @function Phaser.Actions.SetScrollFactor * @since 3.21.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {number} scrollFactorX - The amount to set the `scrollFactorX` property to. * @param {number} [scrollFactorY] - The amount to set the `scrollFactorY` property to. If `undefined` or `null` it uses the `scrollFactorX` value. * @param {number} [stepX=0] - This is added to the `scrollFactorX` amount, multiplied by the iteration counter. * @param {number} [stepY=0] - This is added to the `scrollFactorY` amount, multiplied by the iteration counter. * @param {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. */ var SetScrollFactor = function (items, scrollFactorX, scrollFactorY, stepX, stepY, index, direction) { if (scrollFactorY === undefined || scrollFactorY === null) { scrollFactorY = scrollFactorX; } PropertyValueSet(items, 'scrollFactorX', scrollFactorX, stepX, index, direction); return PropertyValueSet(items, 'scrollFactorY', scrollFactorY, stepY, index, direction); }; module.exports = SetScrollFactor; /***/ }), /***/ 6607: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueSet = __webpack_require__(43967); /** * Takes an array of Game Objects, or any objects that have the public property `scrollFactorX` * 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: `SetScrollFactorX(group.getChildren(), value, step)` * * @function Phaser.Actions.SetScrollFactorX * @since 3.21.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. */ var SetScrollFactorX = function (items, value, step, index, direction) { return PropertyValueSet(items, 'scrollFactorX', value, step, index, direction); }; module.exports = SetScrollFactorX; /***/ }), /***/ 72248: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueSet = __webpack_require__(43967); /** * Takes an array of Game Objects, or any objects that have the public property `scrollFactorY` * 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: `SetScrollFactorY(group.getChildren(), value, step)` * * @function Phaser.Actions.SetScrollFactorY * @since 3.21.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. */ var SetScrollFactorY = function (items, value, step, index, direction) { return PropertyValueSet(items, 'scrollFactorY', value, step, index, direction); }; module.exports = SetScrollFactorY; /***/ }), /***/ 14036: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * Takes an array of Game Objects, or any objects that have the public method setTint() and then updates it to the given value(s). You can specify tint color per corner or provide only one color value for `topLeft` parameter, in which case whole item will be tinted with that color. * * @function Phaser.Actions.SetTint * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. * @param {number} topLeft - The tint being applied to top-left corner of item. If other parameters are given no value, this tint will be applied to whole item. * @param {number} [topRight] - The tint to be applied to top-right corner of item. * @param {number} [bottomLeft] - The tint to be applied to the bottom-left corner of item. * @param {number} [bottomRight] - The tint to be applied to the bottom-right corner of item. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 50159: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueSet = __webpack_require__(43967); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 77597: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueSet = __webpack_require__(43967); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 83194: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueSet = __webpack_require__(43967); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 67678: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var PropertyValueSet = __webpack_require__(43967); /** * 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 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 {number} [index=0] - An optional offset to start searching from within the items array. * @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 35850: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Vector2 = __webpack_require__(26099); /** * Takes an array of items, such as Game Objects, or any objects with public `x` and * `y` properties and then iterates through them. As this function iterates, it moves * the position of the current element to be that of the previous entry in the array. * This repeats until all items have been moved. * * The direction controls the order of iteration. A value of 0 (the default) assumes * that the final item in the array is the 'head' item. * * A direction value of 1 assumes that the first item in the array is the 'head' item. * * The position of the 'head' item is set to the x/y values given to this function. * Every other item in the array is then updated, in sequence, to be that of the * previous (or next) entry in the array. * * The final x/y coords are returned, or set in the 'output' Vector2. * * Think of it as being like the game Snake, where the 'head' is moved and then * each body piece is moved into the space of the previous piece. * * @function Phaser.Actions.ShiftPosition * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items] * @generic {Phaser.Math.Vector2} O - [output,$return] * * @param {(Phaser.Types.Math.Vector2Like[]|Phaser.GameObjects.GameObject[])} items - An array of Game Objects, or objects with public x and y positions. The contents of this array are updated by this Action. * @param {number} x - The x coordinate to place the head item at. * @param {number} y - The y coordinate to place the head item at. * @param {number} [direction=0] - The iteration direction. 0 = first to last and 1 = last to first. * @param {Phaser.Types.Math.Vector2Like} [output] - An optional Vec2Like object to store the final position in. * * @return {Phaser.Types.Math.Vector2Like} 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; var len = items.length; if (len === 1) { px = items[0].x; py = items[0].y; items[0].x = x; items[0].y = y; } else { var i = 1; var pos = 0; if (direction === 0) { pos = len - 1; i = len - 2; } px = items[pos].x; py = items[pos].y; // Update the head item to the new x/y coordinates items[pos].x = x; items[pos].y = y; for (var c = 0; c < len; c++) { if (i >= len || i === -1) { continue; } // Current item var cur = items[i]; // Get current item x/y, to be passed to the next item in the list var cx = cur.x; var 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; if (direction === 0) { i--; } else { i++; } } } // 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; /***/ }), /***/ 8628: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var ArrayShuffle = __webpack_require__(33680); /** * Shuffles the array in place. The shuffled array is both modified and returned. * * @function Phaser.Actions.Shuffle * @since 3.0.0 * @see Phaser.Utils.Array.Shuffle * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ var Shuffle = function (items) { return ArrayShuffle(items); }; module.exports = Shuffle; /***/ }), /***/ 21837: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var MathSmoothStep = __webpack_require__(7602); /** * Smoothstep is a sigmoid-like interpolation and clamping function. * * The function depends on three parameters, the input x, the "left edge" * and the "right edge", with the left edge being assumed smaller than the right edge. * * The function receives a real number x as an argument and returns 0 if x is less than * or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly * interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the * smoothstep function is zero at both edges. * * This is convenient for creating a sequence of transitions using smoothstep to interpolate * each segment as an alternative to using more sophisticated or expensive interpolation techniques. * * @function Phaser.Actions.SmoothStep * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. * @param {string} property - The property of the Game Object to interpolate. * @param {number} min - The minimum interpolation value. * @param {number} max - The maximum interpolation value. * @param {boolean} [inc=false] - Should the property value be incremented (`true`) or set (`false`)? * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 21910: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var MathSmootherStep = __webpack_require__(54261); /** * Smootherstep is a sigmoid-like interpolation and clamping function. * * The function depends on three parameters, the input x, the "left edge" and the "right edge", with the left edge being assumed smaller than the right edge. The function receives a real number x as an argument and returns 0 if x is less than or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the smoothstep function is zero at both edges. This is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques. * * @function Phaser.Actions.SmootherStep * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. * @param {string} property - The property of the Game Object to interpolate. * @param {number} min - The minimum interpolation value. * @param {number} max - The maximum interpolation value. * @param {boolean} [inc=false] - Should the values be incremented? `true` or set (`false`) * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 62054: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * Takes an array of Game Objects and then modifies their `property` so the value equals, or is incremented, by the * calculated spread value. * * The spread value is derived from the given `min` and `max` values and the total number of items in the array. * * For example, to cause an array of Sprites to change in alpha from 0 to 1 you could call: * * ```javascript * Phaser.Actions.Spread(itemsArray, 'alpha', 0, 1); * ``` * * @function Phaser.Actions.Spread * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. * @param {string} property - The property of the Game Object to spread. * @param {number} min - The minimum value. * @param {number} max - The maximum value. * @param {boolean} [inc=false] - Should the values be incremented? `true` or set (`false`) * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that were passed to this Action. */ var Spread = function (items, property, min, max, inc) { if (inc === undefined) { inc = false; } if (items.length === 0) { return items; } if (items.length === 1) // if only one item put it at the center { if (inc) { items[0][property] += (max + min) / 2; } else { items[0][property] = (max + min) / 2; } return items; } var step = Math.abs(max - min) / (items.length - 1); var i; if (inc) { for (i = 0; i < items.length; i++) { items[i][property] += i * step + min; } } else { for (i = 0; i < items.length; i++) { items[i][property] = i * step + min; } } return items; }; module.exports = Spread; /***/ }), /***/ 79815: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * Takes an array of Game Objects and toggles the visibility of each one. * Those previously `visible = false` will become `visible = true`, and vice versa. * * @function Phaser.Actions.ToggleVisible * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 39665: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @author samme * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Wrap = __webpack_require__(15994); /** * Iterates through the given array and makes sure that each objects x and y * properties are wrapped to keep them contained within the given Rectangles * area. * * @function Phaser.Actions.WrapInRectangle * @since 3.0.0 * @see Phaser.Math.Wrap * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @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 which the objects will be wrapped to remain within. * @param {number} [padding=0] - An amount added to each side of the rectangle during the operation. * * @return {(array|Phaser.GameObjects.GameObject[])} 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; /***/ }), /***/ 61061: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Actions */ module.exports = { AlignTo: __webpack_require__(11517), Angle: __webpack_require__(80318), Call: __webpack_require__(60757), GetFirst: __webpack_require__(69927), GetLast: __webpack_require__(32265), GridAlign: __webpack_require__(94420), IncAlpha: __webpack_require__(41721), IncX: __webpack_require__(67285), IncXY: __webpack_require__(9074), IncY: __webpack_require__(75222), PlaceOnCircle: __webpack_require__(22983), PlaceOnEllipse: __webpack_require__(95253), PlaceOnLine: __webpack_require__(88505), PlaceOnRectangle: __webpack_require__(41346), PlaceOnTriangle: __webpack_require__(11575), PlayAnimation: __webpack_require__(29953), PropertyValueInc: __webpack_require__(66979), PropertyValueSet: __webpack_require__(43967), RandomCircle: __webpack_require__(88926), RandomEllipse: __webpack_require__(33286), RandomLine: __webpack_require__(96000), RandomRectangle: __webpack_require__(28789), RandomTriangle: __webpack_require__(97154), Rotate: __webpack_require__(20510), RotateAround: __webpack_require__(91051), RotateAroundDistance: __webpack_require__(76332), ScaleX: __webpack_require__(61619), ScaleXY: __webpack_require__(94868), ScaleY: __webpack_require__(95532), SetAlpha: __webpack_require__(8689), SetBlendMode: __webpack_require__(2645), SetDepth: __webpack_require__(32372), SetHitArea: __webpack_require__(85373), SetOrigin: __webpack_require__(81583), SetRotation: __webpack_require__(79939), SetScale: __webpack_require__(2699), SetScaleX: __webpack_require__(98739), SetScaleY: __webpack_require__(98476), SetScrollFactor: __webpack_require__(6207), SetScrollFactorX: __webpack_require__(6607), SetScrollFactorY: __webpack_require__(72248), SetTint: __webpack_require__(14036), SetVisible: __webpack_require__(50159), SetX: __webpack_require__(77597), SetXY: __webpack_require__(83194), SetY: __webpack_require__(67678), ShiftPosition: __webpack_require__(35850), Shuffle: __webpack_require__(8628), SmootherStep: __webpack_require__(21910), SmoothStep: __webpack_require__(21837), Spread: __webpack_require__(62054), ToggleVisible: __webpack_require__(79815), WrapInRectangle: __webpack_require__(39665) }; /***/ }), /***/ 42099: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Clamp = __webpack_require__(45319); var Class = __webpack_require__(83419); var Events = __webpack_require__(74943); var FindClosestInSorted = __webpack_require__(81957); var Frame = __webpack_require__(41138); var GetValue = __webpack_require__(35154); var SortByDigits = __webpack_require__(90126); /** * @classdesc * A Frame based Animation. * * Animations in Phaser consist of a sequence of `AnimationFrame` objects, which are managed by * this class, along with properties that impact playback, such as the animations frame rate * or delay. * * This class contains all of the properties and methods needed to handle playback of the animation * directly to an `AnimationState` instance, which is owned by a Sprite, or similar Game Object. * * You don't typically create an instance of this class directly, but instead go via * either the `AnimationManager` or the `AnimationState` and use their `create` methods, * depending on if you need a global animation, or local to a specific Sprite. * * @class Animation * @memberof Phaser.Animations * @constructor * @since 3.0.0 * * @param {Phaser.Animations.AnimationManager} manager - A reference to the global Animation Manager * @param {string} key - The unique identifying string for this animation. * @param {Phaser.Types.Animations.Animation} config - The Animation configuration. */ var Animation = new Class({ initialize: function Animation (manager, key, config) { /** * A reference to the global Animation Manager. * * @name Phaser.Animations.Animation#manager * @type {Phaser.Animations.AnimationManager} * @since 3.0.0 */ this.manager = manager; /** * The unique identifying string for this animation. * * @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), GetValue(config, 'sortFrames', true) ); /** * The frame rate of playback in frames per second (default 24 if duration is null) * * @name Phaser.Animations.Animation#frameRate * @type {number} * @default 24 * @since 3.0.0 */ this.frameRate = GetValue(config, 'frameRate', null); /** * How long the animation should play for, in milliseconds. * If the `frameRate` property has been set then it overrides this value, * otherwise the `frameRate` is derived from `duration`. * * @name Phaser.Animations.Animation#duration * @type {number} * @since 3.0.0 */ this.duration = GetValue(config, 'duration', null); /** * How many ms per frame, not including frame specific modifiers. * * @name Phaser.Animations.Animation#msPerFrame * @type {number} * @since 3.0.0 */ this.msPerFrame; /** * Skip frames if the time lags, or always advanced anyway? * * @name Phaser.Animations.Animation#skipMissedFrames * @type {boolean} * @default true * @since 3.0.0 */ this.skipMissedFrames = GetValue(config, 'skipMissedFrames', true); /** * The delay in ms before the playback will begin. * * @name Phaser.Animations.Animation#delay * @type {number} * @default 0 * @since 3.0.0 */ this.delay = GetValue(config, 'delay', 0); /** * Number of times to repeat the animation. Set to -1 to repeat forever. * * @name Phaser.Animations.Animation#repeat * @type {number} * @default 0 * @since 3.0.0 */ this.repeat = GetValue(config, 'repeat', 0); /** * The delay in ms before the a repeat play starts. * * @name Phaser.Animations.Animation#repeatDelay * @type {number} * @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); /** * If the animation has a delay set, before playback will begin, this * controls when the first frame is set on the Sprite. If this property * is 'false' then the frame is set only after the delay has expired. * This is the default behavior. * * @name Phaser.Animations.Animation#showBeforeDelay * @type {boolean} * @default false * @since 3.60.0 */ this.showBeforeDelay = GetValue(config, 'showBeforeDelay', false); /** * Should the GameObject's `visible` property be set to `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 the GameObject's `visible` property be set to `false` when the animation finishes? * * @name Phaser.Animations.Animation#hideOnComplete * @type {boolean} * @default false * @since 3.0.0 */ this.hideOnComplete = GetValue(config, 'hideOnComplete', false); /** * Start playback of this animation from a random frame? * * @name Phaser.Animations.Animation#randomFrame * @type {boolean} * @default false * @since 3.60.0 */ this.randomFrame = GetValue(config, 'randomFrame', false); /** * Global pause. All Game Objects using this Animation instance are impacted by this property. * * @name Phaser.Animations.Animation#paused * @type {boolean} * @default false * @since 3.0.0 */ this.paused = false; this.calculateDuration(this, this.getTotalFrames(), this.duration, this.frameRate); if (this.manager.on) { this.manager.on(Events.PAUSE_ALL, this.pause, this); this.manager.on(Events.RESUME_ALL, this.resume, this); } }, /** * Gets the total number of frames in this animation. * * @method Phaser.Animations.Animation#getTotalFrames * @since 3.50.0 * * @return {number} The total number of frames in this animation. */ getTotalFrames: function () { return this.frames.length; }, /** * Calculates the duration, frame rate and msPerFrame values. * * @method Phaser.Animations.Animation#calculateDuration * @since 3.50.0 * * @param {Phaser.Animations.Animation} target - The target to set the values on. * @param {number} totalFrames - The total number of frames in the animation. * @param {?number} [duration] - The duration to calculate the frame rate from. Pass `null` if you wish to set the `frameRate` instead. * @param {?number} [frameRate] - The frame rate to calculate the duration from. */ calculateDuration: function (target, totalFrames, duration, frameRate) { if (duration === null && frameRate === null) { // No duration or frameRate given, use default frameRate of 24fps target.frameRate = 24; target.duration = (24 / totalFrames) * 1000; } else if (duration && frameRate === null) { // Duration given but no frameRate, so set the frameRate based on duration // I.e. 12 frames in the animation, duration = 4000 ms // So frameRate is 12 / (4000 / 1000) = 3 fps target.duration = duration; target.frameRate = totalFrames / (duration / 1000); } 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 * 1000 (half a second, or 500ms) target.frameRate = frameRate; target.duration = (totalFrames / frameRate) * 1000; } target.msPerFrame = 1000 / target.frameRate; }, /** * Add frames to the end of the animation. * * @method Phaser.Animations.Animation#addFrame * @since 3.0.0 * * @param {(string|Phaser.Types.Animations.AnimationFrame[])} config - Either a string, in which case it will use all frames from a texture with the matching key, or an array of Animation Frame configuration objects. * * @return {this} This Animation object. */ addFrame: function (config) { return this.addFrameAt(this.frames.length, config); }, /** * Add frame/s into the animation. * * @method Phaser.Animations.Animation#addFrameAt * @since 3.0.0 * * @param {number} index - The index to insert the frame at within the animation. * @param {(string|Phaser.Types.Animations.AnimationFrame[])} config - Either a string, in which case it will use all frames from a texture with the matching key, or an array of Animation Frame configuration objects. * * @return {this} 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; }, /** * Check if the given frame index is valid. * * @method Phaser.Animations.Animation#checkFrame * @since 3.0.0 * * @param {number} index - The index to be checked. * * @return {boolean} `true` if the index is valid, otherwise `false`. */ checkFrame: function (index) { return (index >= 0 && index < this.frames.length); }, /** * Called internally when this Animation first starts to play. * Sets the accumulator and nextTick properties. * * @method Phaser.Animations.Animation#getFirstTick * @protected * @since 3.0.0 * * @param {Phaser.Animations.AnimationState} state - The Animation State belonging to the Game Object invoking this call. */ getFirstTick: function (state) { // When is the first update due? state.accumulator = 0; state.nextTick = (state.currentFrame.duration) ? state.currentFrame.duration : state.msPerFrame; }, /** * Returns the AnimationFrame at the provided index * * @method Phaser.Animations.Animation#getFrameAt * @since 3.0.0 * * @param {number} index - The index in the AnimationFrame array * * @return {Phaser.Animations.AnimationFrame} The frame at the index provided from the animation sequence */ getFrameAt: function (index) { return this.frames[index]; }, /** * Creates AnimationFrame instances based on the given frame data. * * @method Phaser.Animations.Animation#getFrames * @since 3.0.0 * * @param {Phaser.Textures.TextureManager} textureManager - A reference to the global Texture Manager. * @param {(string|Phaser.Types.Animations.AnimationFrame[])} frames - Either a string, in which case it will use all frames from a texture with the matching key, or an array of Animation Frame configuration objects. * @param {string} [defaultTextureKey] - The key to use if no key is set in the frame configuration object. * * @return {Phaser.Animations.AnimationFrame[]} An array of newly created AnimationFrame instances. */ getFrames: function (textureManager, frames, defaultTextureKey, sortFrames) { if (sortFrames === undefined) { sortFrames = true; } 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; if (!textureManager.exists(textureKey)) { console.warn('Texture "%s" not found', textureKey); return out; } var texture = textureManager.get(textureKey); var frameKeys = texture.getFrameNames(); if (sortFrames) { SortByDigits(frameKeys); } frames = []; frameKeys.forEach(function (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); if (!textureFrame) { console.warn('Texture "%s" not found', key); continue; } animationFrame = new Frame(key, frame, index, textureFrame); animationFrame.duration = GetValue(item, 'duration', 0); 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; }, /** * Called internally. Sets the accumulator and nextTick values of the current Animation. * * @method Phaser.Animations.Animation#getNextTick * @since 3.0.0 * * @param {Phaser.Animations.AnimationState} state - The Animation State belonging to the Game Object invoking this call. */ getNextTick: function (state) { state.accumulator -= state.nextTick; state.nextTick = (state.currentFrame.duration) ? state.currentFrame.duration : state.msPerFrame; }, /** * Returns the frame closest to the given progress value between 0 and 1. * * @method Phaser.Animations.Animation#getFrameByProgress * @since 3.4.0 * * @param {number} value - A value between 0 and 1. * * @return {Phaser.Animations.AnimationFrame} The frame closest to the given progress value. */ getFrameByProgress: function (value) { value = Clamp(value, 0, 1); return FindClosestInSorted(value, this.frames, 'progress'); }, /** * Advance the animation frame. * * @method Phaser.Animations.Animation#nextFrame * @since 3.0.0 * * @param {Phaser.Animations.AnimationState} state - The Animation State to advance. */ nextFrame: function (state) { var frame = state.currentFrame; if (frame.isLast) { // We're at the end of the animation // Yoyo? (happens before repeat) if (state.yoyo) { this.handleYoyoFrame(state, false); } else if (state.repeatCounter > 0) { // Repeat (happens before complete) if (state.inReverse && state.forward) { state.forward = false; } else { this.repeatAnimation(state); } } else { state.complete(); } } else { this.updateAndGetNextTick(state, frame.nextFrame); } }, /** * Handle the yoyo functionality in nextFrame and previousFrame methods. * * @method Phaser.Animations.Animation#handleYoyoFrame * @private * @since 3.12.0 * * @param {Phaser.Animations.AnimationState} state - The Animation State to advance. * @param {boolean} isReverse - Is animation in reverse mode? (Default: false) */ handleYoyoFrame: function (state, isReverse) { if (!isReverse) { isReverse = false; } if (state.inReverse === !isReverse && state.repeatCounter > 0) { if (state.repeatDelay === 0 || state.pendingRepeat) { state.forward = isReverse; } this.repeatAnimation(state); return; } if (state.inReverse !== isReverse && state.repeatCounter === 0) { state.complete(); return; } state.forward = isReverse; var frame = (isReverse) ? state.currentFrame.nextFrame : state.currentFrame.prevFrame; this.updateAndGetNextTick(state, frame); }, /** * Returns the animation last frame. * * @method Phaser.Animations.Animation#getLastFrame * @since 3.12.0 * * @return {Phaser.Animations.AnimationFrame} The last Animation Frame. */ getLastFrame: function () { return this.frames[this.frames.length - 1]; }, /** * Called internally when the Animation is playing backwards. * Sets the previous frame, causing a yoyo, repeat, complete or update, accordingly. * * @method Phaser.Animations.Animation#previousFrame * @since 3.0.0 * * @param {Phaser.Animations.AnimationState} state - The Animation State belonging to the Game Object invoking this call. */ previousFrame: function (state) { var frame = state.currentFrame; if (frame.isFirst) { // We're at the start of the animation if (state.yoyo) { this.handleYoyoFrame(state, true); } else if (state.repeatCounter > 0) { if (state.inReverse && !state.forward) { this.repeatAnimation(state); } else { // Repeat (happens before complete) state.forward = true; this.repeatAnimation(state); } } else { state.complete(); } } else { this.updateAndGetNextTick(state, frame.prevFrame); } }, /** * Update Frame and Wait next tick. * * @method Phaser.Animations.Animation#updateAndGetNextTick * @private * @since 3.12.0 * * @param {Phaser.Animations.AnimationState} state - The Animation State. * @param {Phaser.Animations.AnimationFrame} frame - An Animation frame. */ updateAndGetNextTick: function (state, frame) { state.setCurrentFrame(frame); this.getNextTick(state); }, /** * Removes the given AnimationFrame from this Animation instance. * This is a global action. Any Game Object using this Animation will be impacted by this change. * * @method Phaser.Animations.Animation#removeFrame * @since 3.0.0 * * @param {Phaser.Animations.AnimationFrame} frame - The AnimationFrame to be removed. * * @return {this} This Animation object. */ removeFrame: function (frame) { var index = this.frames.indexOf(frame); if (index !== -1) { this.removeFrameAt(index); } return this; }, /** * Removes a frame from the AnimationFrame array at the provided index * and updates the animation accordingly. * * @method Phaser.Animations.Animation#removeFrameAt * @since 3.0.0 * * @param {number} index - The index in the AnimationFrame array * * @return {this} This Animation object. */ removeFrameAt: function (index) { this.frames.splice(index, 1); this.updateFrameSequence(); return this; }, /** * Called internally during playback. Forces the animation to repeat, providing there are enough counts left * in the repeat counter. * * @method Phaser.Animations.Animation#repeatAnimation * @fires Phaser.Animations.Events#ANIMATION_REPEAT * @fires Phaser.Animations.Events#SPRITE_ANIMATION_REPEAT * @fires Phaser.Animations.Events#SPRITE_ANIMATION_KEY_REPEAT * @since 3.0.0 * * @param {Phaser.Animations.AnimationState} state - The Animation State belonging to the Game Object invoking this call. */ repeatAnimation: function (state) { if (state._pendingStop === 2) { if (state._pendingStopValue === 0) { return state.stop(); } else { state._pendingStopValue--; } } if (state.repeatDelay > 0 && !state.pendingRepeat) { state.pendingRepeat = true; state.accumulator -= state.nextTick; state.nextTick += state.repeatDelay; } else { state.repeatCounter--; if (state.forward) { state.setCurrentFrame(state.currentFrame.nextFrame); } else { state.setCurrentFrame(state.currentFrame.prevFrame); } if (state.isPlaying) { this.getNextTick(state); state.handleRepeat(); } } }, /** * Converts the animation data to JSON. * * @method Phaser.Animations.Animation#toJSON * @since 3.0.0 * * @return {Phaser.Types.Animations.JSONAnimation} The resulting JSONAnimation formatted object. */ 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, showBeforeDelay: this.showBeforeDelay, showOnStart: this.showOnStart, randomFrame: this.randomFrame, hideOnComplete: this.hideOnComplete }; this.frames.forEach(function (frame) { output.frames.push(frame.toJSON()); }); return output; }, /** * Called internally whenever frames are added to, or removed from, this Animation. * * @method Phaser.Animations.Animation#updateFrameSequence * @since 3.0.0 * * @return {this} This Animation object. */ updateFrameSequence: function () { var len = this.frames.length; var slice = 1 / (len - 1); var frame; for (var i = 0; i < len; i++) { frame = this.frames[i]; frame.index = i + 1; frame.isFirst = false; frame.isLast = false; frame.progress = i * slice; if (i === 0) { frame.isFirst = true; if (len === 1) { frame.isLast = true; frame.nextFrame = frame; frame.prevFrame = frame; } else { frame.isLast = false; frame.prevFrame = this.frames[len - 1]; frame.nextFrame = this.frames[i + 1]; } } else if (i === len - 1 && 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; }, /** * Pauses playback of this Animation. The paused state is set immediately. * * @method Phaser.Animations.Animation#pause * @since 3.0.0 * * @return {this} This Animation object. */ pause: function () { this.paused = true; return this; }, /** * Resumes playback of this Animation. The paused state is reset immediately. * * @method Phaser.Animations.Animation#resume * @since 3.0.0 * * @return {this} This Animation object. */ resume: function () { this.paused = false; return this; }, /** * Destroys this Animation instance. It will remove all event listeners, * remove this animation and its key from the global Animation Manager, * and then destroy all Animation Frames in turn. * * @method Phaser.Animations.Animation#destroy * @since 3.0.0 */ destroy: function () { if (this.manager.off) { this.manager.off(Events.PAUSE_ALL, this.pause, this); this.manager.off(Events.RESUME_ALL, this.resume, this); } this.manager.remove(this.key); for (var i = 0; i < this.frames.length; i++) { this.frames[i].destroy(); } this.frames = []; this.manager = null; } }); module.exports = Animation; /***/ }), /***/ 41138: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Class = __webpack_require__(83419); /** * @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 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|number)} textureFrame - The key of the Frame within the Texture that this AnimationFrame uses. * @param {number} 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. * @param {boolean} [isKeyFrame=false] - Is this Frame a Keyframe within the Animation? */ var AnimationFrame = new Class({ initialize: function AnimationFrame (textureKey, textureFrame, index, frame, isKeyFrame) { if (isKeyFrame === undefined) { isKeyFrame = false; } /** * 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|number)} * @since 3.0.0 */ this.textureFrame = textureFrame; /** * The index of this AnimationFrame within the Animation sequence. * * @name Phaser.Animations.AnimationFrame#index * @type {number} * @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; /** * The duration, in ms, of this frame of 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; /** * Is this Frame a KeyFrame within the Animation? * * @name Phaser.Animations.AnimationFrame#isKeyFrame * @type {boolean} * @since 3.50.0 */ this.isKeyFrame = isKeyFrame; }, /** * Generates a JavaScript object suitable for converting to JSON. * * @method Phaser.Animations.AnimationFrame#toJSON * @since 3.0.0 * * @return {Phaser.Types.Animations.JSONAnimationFrame} The AnimationFrame data. */ toJSON: function () { return { key: this.textureKey, frame: this.textureFrame, duration: this.duration, keyframe: this.isKeyFrame }; }, /** * 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; } }); module.exports = AnimationFrame; /***/ }), /***/ 60848: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Animation = __webpack_require__(42099); var Class = __webpack_require__(83419); var CustomMap = __webpack_require__(90330); var EventEmitter = __webpack_require__(50792); var Events = __webpack_require__(74943); var GameEvents = __webpack_require__(8443); var GetFastValue = __webpack_require__(95540); var GetValue = __webpack_require__(35154); var MATH_CONST = __webpack_require__(36383); var NumberArray = __webpack_require__(20283); var Pad = __webpack_require__(41836); /** * @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 Phaser.Events.EventEmitter * @memberof Phaser.Animations * @constructor * @since 3.0.0 * * @param {Phaser.Game} game - A reference to the Phaser.Game instance. */ var AnimationManager = new Class({ Extends: EventEmitter, initialize: function AnimationManager (game) { EventEmitter.call(this); /** * A reference to the Phaser.Game instance. * * @name Phaser.Animations.AnimationManager#game * @type {Phaser.Game} * @protected * @since 3.0.0 */ this.game = game; /** * A reference to the Texture Manager. * * @name Phaser.Animations.AnimationManager#textureManager * @type {Phaser.Textures.TextureManager} * @protected * @since 3.0.0 */ this.textureManager = null; /** * The global time scale of the Animation Manager. * * This scales the time delta between two frames, thus influencing the speed of time for the Animation Manager. * * @name Phaser.Animations.AnimationManager#globalTimeScale * @type {number} * @default 1 * @since 3.0.0 */ this.globalTimeScale = 1; /** * The Animations registered in the Animation Manager. * * This map should be modified with the {@link #add} and {@link #create} methods of the Animation Manager. * * @name Phaser.Animations.AnimationManager#anims * @type {Phaser.Structs.Map.} * @protected * @since 3.0.0 */ this.anims = new CustomMap(); /** * A list of animation mix times. * * See the {@link #setMix} method for more details. * * @name Phaser.Animations.AnimationManager#mixes * @type {Phaser.Structs.Map.} * @since 3.50.0 */ this.mixes = new CustomMap(); /** * Whether the Animation Manager is paused along with all of its Animations. * * @name Phaser.Animations.AnimationManager#paused * @type {boolean} * @default false * @since 3.0.0 */ this.paused = false; /** * The name of this Animation Manager. * * @name Phaser.Animations.AnimationManager#name * @type {string} * @since 3.0.0 */ this.name = 'AnimationManager'; game.events.once(GameEvents.BOOT, this.boot, this); }, /** * Registers event listeners after the Game boots. * * @method Phaser.Animations.AnimationManager#boot * @listens Phaser.Core.Events#DESTROY * @since 3.0.0 */ boot: function () { this.textureManager = this.game.textures; this.game.events.once(GameEvents.DESTROY, this.destroy, this); }, /** * Adds a mix between two animations. * * Mixing allows you to specify a unique delay between a pairing of animations. * * When playing Animation A on a Game Object, if you then play Animation B, and a * mix exists, it will wait for the specified delay to be over before playing Animation B. * * This allows you to customise smoothing between different types of animation, such * as blending between an idle and a walk state, or a running and a firing state. * * Note that mixing is only applied if you use the `Sprite.play` method. If you opt to use * `playAfterRepeat` or `playAfterDelay` instead, those will take priority and the mix * delay will not be used. * * To update an existing mix, just call this method with the new delay. * * To remove a mix pairing, see the `removeMix` method. * * @method Phaser.Animations.AnimationManager#addMix * @since 3.50.0 * * @param {(string|Phaser.Animations.Animation)} animA - The string-based key, or instance of, Animation A. * @param {(string|Phaser.Animations.Animation)} animB - The string-based key, or instance of, Animation B. * @param {number} delay - The delay, in milliseconds, to wait when transitioning from Animation A to B. * * @return {this} This Animation Manager. */ addMix: function (animA, animB, delay) { var anims = this.anims; var mixes = this.mixes; var keyA = (typeof(animA) === 'string') ? animA : animA.key; var keyB = (typeof(animB) === 'string') ? animB : animB.key; if (anims.has(keyA) && anims.has(keyB)) { var mixObj = mixes.get(keyA); if (!mixObj) { mixObj = {}; } mixObj[keyB] = delay; mixes.set(keyA, mixObj); } return this; }, /** * Removes a mix between two animations. * * Mixing allows you to specify a unique delay between a pairing of animations. * * Calling this method lets you remove those pairings. You can either remove * it between `animA` and `animB`, or if you do not provide the `animB` parameter, * it will remove all `animA` mixes. * * If you wish to update an existing mix instead, call the `addMix` method with the * new delay. * * @method Phaser.Animations.AnimationManager#removeMix * @since 3.50.0 * * @param {(string|Phaser.Animations.Animation)} animA - The string-based key, or instance of, Animation A. * @param {(string|Phaser.Animations.Animation)} [animB] - The string-based key, or instance of, Animation B. If not given, all mixes for Animation A will be removed. * * @return {this} This Animation Manager. */ removeMix: function (animA, animB) { var mixes = this.mixes; var keyA = (typeof(animA) === 'string') ? animA : animA.key; var mixObj = mixes.get(keyA); if (mixObj) { if (animB) { var keyB = (typeof(animB) === 'string') ? animB : animB.key; if (mixObj.hasOwnProperty(keyB)) { // Remove just this pairing delete mixObj[keyB]; } } else if (!animB) { // Remove everything for animA mixes.delete(keyA); } } return this; }, /** * Returns the mix delay between two animations. * * If no mix has been set-up, this method will return zero. * * If you wish to create, or update, a new mix, call the `addMix` method. * If you wish to remove a mix, call the `removeMix` method. * * @method Phaser.Animations.AnimationManager#getMix * @since 3.50.0 * * @param {(string|Phaser.Animations.Animation)} animA - The string-based key, or instance of, Animation A. * @param {(string|Phaser.Animations.Animation)} animB - The string-based key, or instance of, Animation B. * * @return {number} The mix duration, or zero if no mix exists. */ getMix: function (animA, animB) { var mixes = this.mixes; var keyA = (typeof(animA) === 'string') ? animA : animA.key; var keyB = (typeof(animB) === 'string') ? animB : animB.key; var mixObj = mixes.get(keyA); if (mixObj && mixObj.hasOwnProperty(keyB)) { return mixObj[keyB]; } else { return 0; } }, /** * Adds an existing Animation to the Animation Manager. * * @method Phaser.Animations.AnimationManager#add * @fires Phaser.Animations.Events#ADD_ANIMATION * @since 3.0.0 * * @param {string} key - The key under which the Animation should be added. The Animation will be updated with it. Must be unique. * @param {Phaser.Animations.Animation} animation - The Animation which should be added to the Animation Manager. * * @return {this} This Animation Manager. */ add: function (key, animation) { if (this.anims.has(key)) { console.warn('Animation key exists: ' + key); return this; } animation.key = key; this.anims.set(key, animation); this.emit(Events.ADD_ANIMATION, key, animation); return this; }, /** * Checks to see if the given key is already in use within the Animation Manager or not. * * Animations are global. Keys created in one scene can be used from any other Scene in your game. They are not Scene specific. * * @method Phaser.Animations.AnimationManager#exists * @since 3.16.0 * * @param {string} key - The key of the Animation to check. * * @return {boolean} `true` if the Animation already exists in the Animation Manager, or `false` if the key is available. */ exists: function (key) { return this.anims.has(key); }, /** * Create one, or more animations from a loaded Aseprite JSON file. * * Aseprite is a powerful animated sprite editor and pixel art tool. * * You can find more details at https://www.aseprite.org/ * * To export a compatible JSON file in Aseprite, please do the following: * * 1. Go to "File - Export Sprite Sheet" * * 2. On the **Layout** tab: * 2a. Set the "Sheet type" to "Packed" * 2b. Set the "Constraints" to "None" * 2c. Check the "Merge Duplicates" checkbox * * 3. On the **Sprite** tab: * 3a. Set "Layers" to "Visible layers" * 3b. Set "Frames" to "All frames", unless you only wish to export a sub-set of tags * * 4. On the **Borders** tab: * 4a. Check the "Trim Sprite" and "Trim Cells" options * 4b. Ensure "Border Padding", "Spacing" and "Inner Padding" are all > 0 (1 is usually enough) * * 5. On the **Output** tab: * 5a. Check "Output File", give your image a name and make sure you choose "png files" as the file type * 5b. Check "JSON Data" and give your json file a name * 5c. The JSON Data type can be either a Hash or Array, Phaser doesn't mind. * 5d. Make sure "Tags" is checked in the Meta options * 5e. In the "Item Filename" input box, make sure it says just "{frame}" and nothing more. * * 6. Click export * * This was tested with Aseprite 1.2.25. * * This will export a png and json file which you can load using the Aseprite Loader, i.e.: * * ```javascript * function preload () * { * this.load.path = 'assets/animations/aseprite/'; * this.load.aseprite('paladin', 'paladin.png', 'paladin.json'); * } * ``` * * Once loaded, you can call this method from within a Scene with the 'atlas' key: * * ```javascript * this.anims.createFromAseprite('paladin'); * ``` * * Any animations defined in the JSON will now be available to use in Phaser and you play them * via their Tag name. For example, if you have an animation called 'War Cry' on your Aseprite timeline, * you can play it in Phaser using that Tag name: * * ```javascript * this.add.sprite(400, 300).play('War Cry'); * ``` * * When calling this method you can optionally provide an array of tag names, and only those animations * will be created. For example: * * ```javascript * this.anims.createFromAseprite('paladin', [ 'step', 'War Cry', 'Magnum Break' ]); * ``` * * This will only create the 3 animations defined. Note that the tag names are case-sensitive. * * @method Phaser.Animations.AnimationManager#createFromAseprite * @since 3.50.0 * * @param {string} key - The key of the loaded Aseprite atlas. It must have been loaded prior to calling this method. * @param {string[]} [tags] - An array of Tag names. If provided, only animations found in this array will be created. * @param {(Phaser.Animations.AnimationManager|Phaser.GameObjects.GameObject)} [target] - Create the animations on this target Sprite. If not given, they will be created globally in this Animation Manager. * * @return {Phaser.Animations.Animation[]} An array of Animation instances that were successfully created. */ createFromAseprite: function (key, tags, target) { var output = []; var data = this.game.cache.json.get(key); if (!data) { console.warn('No Aseprite data found for: ' + key); return output; } var _this = this; var meta = GetValue(data, 'meta', null); var frames = GetValue(data, 'frames', null); if (meta && frames) { var frameTags = GetValue(meta, 'frameTags', []); frameTags.forEach(function (tag) { var animFrames = []; var name = GetFastValue(tag, 'name', null); var from = GetFastValue(tag, 'from', 0); var to = GetFastValue(tag, 'to', 0); var direction = GetFastValue(tag, 'direction', 'forward'); if (!name) { // Skip if no name return; } if (!tags || (tags && tags.indexOf(name) > -1)) { // Get all the frames for this tag and calculate the total duration in milliseconds. var totalDuration = 0; for (var i = from; i <= to; i++) { var frameKey = i.toString(); var frame = frames[frameKey]; if (frame) { var frameDuration = GetFastValue(frame, 'duration', MATH_CONST.MAX_SAFE_INTEGER); animFrames.push({ key: key, frame: frameKey, duration: frameDuration }); totalDuration += frameDuration; } } if (direction === 'reverse') { animFrames = animFrames.reverse(); } // Create the animation var createConfig = { key: name, frames: animFrames, duration: totalDuration, yoyo: (direction === 'pingpong') }; var result; if (target) { if (target.anims) { result = target.anims.create(createConfig); } } else { result = _this.create(createConfig); } if (result) { output.push(result); } } }); } return output; }, /** * Creates a new Animation and adds it to the Animation Manager. * * Animations are global. Once created, you can use them in any Scene in your game. They are not Scene specific. * * If an invalid key is given this method will return `false`. * * If you pass the key of an animation that already exists in the Animation Manager, that animation will be returned. * * A brand new animation is only created if the key is valid and not already in use. * * If you wish to re-use an existing key, call `AnimationManager.remove` first, then this method. * * @method Phaser.Animations.AnimationManager#create * @fires Phaser.Animations.Events#ADD_ANIMATION * @since 3.0.0 * * @param {Phaser.Types.Animations.Animation} config - The configuration settings for the Animation. * * @return {(Phaser.Animations.Animation|false)} The Animation that was created, or `false` if the key is already in use. */ create: function (config) { var key = config.key; var anim = false; if (key) { anim = this.get(key); if (!anim) { anim = new Animation(this, key, config); this.anims.set(key, anim); this.emit(Events.ADD_ANIMATION, key, anim); } else { console.warn('AnimationManager key already exists: ' + key); } } return anim; }, /** * Loads this Animation Manager's Animations and settings from a JSON object. * * @method Phaser.Animations.AnimationManager#fromJSON * @since 3.0.0 * * @param {(string|Phaser.Types.Animations.JSONAnimations|Phaser.Types.Animations.JSONAnimation)} data - The JSON object to parse. * @param {boolean} [clearCurrentAnimations=false] - If set to `true`, the current animations will be removed (`anims.clear()`). If set to `false` (default), the animations in `data` will be added. * * @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; }, /** * Generate an array of {@link Phaser.Types.Animations.AnimationFrame} objects from a texture key and configuration object. * * Generates objects with string based frame names, as configured by the given {@link Phaser.Types.Animations.GenerateFrameNames}. * * It's a helper method, designed to make it easier for you to extract all of the frame names from texture atlases. * * If you're working with a sprite sheet, see the `generateFrameNumbers` method instead. * * Example: * * If you have a texture atlases loaded called `gems` and it contains 6 frames called `ruby_0001`, `ruby_0002`, and so on, * then you can call this method using: `this.anims.generateFrameNames('gems', { prefix: 'ruby_', start: 1, end: 6, zeroPad: 4 })`. * * The `end` value tells it to select frames 1 through 6, incrementally numbered, all starting with the prefix `ruby_`. The `zeroPad` * value tells it how many zeroes pad out the numbers. To create an animation using this method, you can do: * * ```javascript * this.anims.create({ * key: 'ruby', * repeat: -1, * frames: this.anims.generateFrameNames('gems', { * prefix: 'ruby_', * end: 6, * zeroPad: 4 * }) * }); * ``` * * Please see the animation examples for further details. * * @method Phaser.Animations.AnimationManager#generateFrameNames * @since 3.0.0 * * @param {string} key - The key for the texture containing the animation frames. * @param {Phaser.Types.Animations.GenerateFrameNames} [config] - The configuration object for the animation frame names. * * @return {Phaser.Types.Animations.AnimationFrame[]} The array of {@link Phaser.Types.Animations.AnimationFrame} objects. */ 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); if (!this.textureManager.exists(key)) { console.warn('Texture "%s" not found', key); return out; } var texture = this.textureManager.get(key); if (!texture) { return out; } var i; if (!config) { // Use every frame in the atlas frames = texture.getFrameNames(); for (i = 0; i < frames.length; i++) { out.push({ key: key, frame: frames[i] }); } } else { if (!frames) { frames = NumberArray(start, end); } for (i = 0; i < frames.length; i++) { var frame = prefix + Pad(frames[i], zeroPad, '0', 1) + suffix; if (texture.has(frame)) { out.push({ key: key, frame: frame }); } else { console.warn('Frame "%s" not found in texture "%s"', frame, key); } } } return out; }, /** * Generate an array of {@link Phaser.Types.Animations.AnimationFrame} objects from a texture key and configuration object. * * Generates objects with numbered frame names, as configured by the given {@link Phaser.Types.Animations.GenerateFrameNumbers}. * * If you're working with a texture atlas, see the `generateFrameNames` method instead. * * It's a helper method, designed to make it easier for you to extract frames from sprite sheets. * * Example: * * If you have a sprite sheet loaded called `explosion` and it contains 12 frames, then you can call this method using: * * `this.anims.generateFrameNumbers('explosion', { start: 0, end: 11 })`. * * The `end` value of 11 tells it to stop after the 12th frame has been added, because it started at zero. * * To create an animation using this method, you can do: * * ```javascript * this.anims.create({ * key: 'boom', * frames: this.anims.generateFrameNumbers('explosion', { * start: 0, * end: 11 * }) * }); * ``` * * Note that `start` is optional and you don't need to include it if the animation starts from frame 0. * * To specify an animation in reverse, swap the `start` and `end` values. * * If the frames are not sequential, you may pass an array of frame numbers instead, for example: * * `this.anims.generateFrameNumbers('explosion', { frames: [ 0, 1, 2, 1, 2, 3, 4, 0, 1, 2 ] })` * * Please see the animation examples and `GenerateFrameNumbers` config docs for further details. * * @method Phaser.Animations.AnimationManager#generateFrameNumbers * @since 3.0.0 * * @param {string} key - The key for the texture containing the animation frames. * @param {Phaser.Types.Animations.GenerateFrameNumbers} [config] - The configuration object for the animation frames. * * @return {Phaser.Types.Animations.AnimationFrame[]} The array of {@link Phaser.Types.Animations.AnimationFrame} objects. */ generateFrameNumbers: function (key, config) { var start = GetValue(config, 'start', 0); var end = GetValue(config, 'end', -1); var first = GetValue(config, 'first', false); var out = GetValue(config, 'outputArray', []); var frames = GetValue(config, 'frames', false); if (!this.textureManager.exists(key)) { console.warn('Texture "%s" not found', key); return out; } var texture = this.textureManager.get(key); if (!texture) { return out; } if (first && texture.has(first)) { out.push({ key: key, frame: first }); } // No 'frames' array? Then generate one automatically if (!frames) { if (end === -1) { // -1 because of __BASE, which we don't want in our results // and -1 because frames are zero based end = texture.frameTotal - 2; } frames = NumberArray(start, end); } for (var i = 0; i < frames.length; i++) { var frameName = frames[i]; if (texture.has(frameName)) { out.push({ key: key, frame: frameName }); } else { console.warn('Frame "%s" not found in texture "%s"', frameName, key); } } return out; }, /** * Get an Animation. * * @method Phaser.Animations.AnimationManager#get * @since 3.0.0 * * @param {string} key - The key of the Animation to retrieve. * * @return {Phaser.Animations.Animation} The Animation. */ get: function (key) { return this.anims.get(key); }, /** * Returns an array of all Animation keys that are using the given * Texture. Only Animations that have at least one AnimationFrame * entry using this texture will be included in the result. * * @method Phaser.Animations.AnimationManager#getAnimsFromTexture * @since 3.60.0 * * @param {(string|Phaser.Textures.Texture|Phaser.Textures.Frame)} key - The unique string-based key of the Texture, or a Texture, or Frame instance. * * @return {string[]} An array of Animation keys that feature the given Texture. */ getAnimsFromTexture: function (key) { var texture = this.textureManager.get(key); var match = texture.key; var anims = this.anims.getArray(); var out = []; for (var i = 0; i < anims.length; i++) { var anim = anims[i]; var frames = anim.frames; for (var c = 0; c < frames.length; c++) { if (frames[c].textureKey === match) { out.push(anim.key); break; } } } return out; }, /** * Pause all animations. * * @method Phaser.Animations.AnimationManager#pauseAll * @fires Phaser.Animations.Events#PAUSE_ALL * @since 3.0.0 * * @return {this} This Animation Manager. */ pauseAll: function () { if (!this.paused) { this.paused = true; this.emit(Events.PAUSE_ALL); } return this; }, /** * Play an animation on the given Game Objects that have an Animation Component. * * @method Phaser.Animations.AnimationManager#play * @since 3.0.0 * * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} children - An array of Game Objects to play the animation on. They must have an Animation Component. * * @return {this} This Animation Manager. */ play: function (key, children) { if (!Array.isArray(children)) { children = [ children ]; } for (var i = 0; i < children.length; i++) { children[i].anims.play(key); } return this; }, /** * Takes an array of Game Objects that have an Animation Component and then * starts the given animation playing on them. The start time of each Game Object * is offset, incrementally, by the `stagger` amount. * * For example, if you pass an array with 4 children and a stagger time of 1000, * the delays will be: * * child 1: 1000ms delay * child 2: 2000ms delay * child 3: 3000ms delay * child 4: 4000ms delay * * If you set the `staggerFirst` parameter to `false` they would be: * * child 1: 0ms delay * child 2: 1000ms delay * child 3: 2000ms delay * child 4: 3000ms delay * * You can also set `stagger` to be a negative value. If it was -1000, the above would be: * * child 1: 3000ms delay * child 2: 2000ms delay * child 3: 1000ms delay * child 4: 0ms delay * * @method Phaser.Animations.AnimationManager#staggerPlay * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} children - An array of Game Objects to play the animation on. They must have an Animation Component. * @param {number} stagger - The amount of time, in milliseconds, to offset each play time by. If a negative value is given, it's applied to the children in reverse order. * @param {boolean} [staggerFirst=true] -Should the first child be staggered as well? * * @return {this} This Animation Manager. */ staggerPlay: function (key, children, stagger, staggerFirst) { if (stagger === undefined) { stagger = 0; } if (staggerFirst === undefined) { staggerFirst = true; } if (!Array.isArray(children)) { children = [ children ]; } var len = children.length; if (!staggerFirst) { len--; } for (var i = 0; i < children.length; i++) { var time = (stagger < 0) ? Math.abs(stagger) * (len - i) : stagger * i; children[i].anims.playAfterDelay(key, time); } return this; }, /** * Removes an Animation from this Animation Manager, based on the given key. * * This is a global action. Once an Animation has been removed, no Game Objects * can carry on using it. * * @method Phaser.Animations.AnimationManager#remove * @fires Phaser.Animations.Events#REMOVE_ANIMATION * @since 3.0.0 * * @param {string} key - The key of the animation to remove. * * @return {Phaser.Animations.Animation} The Animation instance that was removed from the Animation Manager. */ remove: function (key) { var anim = this.get(key); if (anim) { this.emit(Events.REMOVE_ANIMATION, key, anim); this.anims.delete(key); this.removeMix(key); } return anim; }, /** * Resume all paused animations. * * @method Phaser.Animations.AnimationManager#resumeAll * @fires Phaser.Animations.Events#RESUME_ALL * @since 3.0.0 * * @return {this} This Animation Manager. */ resumeAll: function () { if (this.paused) { this.paused = false; this.emit(Events.RESUME_ALL); } return this; }, /** * Returns the Animation data as JavaScript object based on the given key. * Or, if not key is defined, it will return the data of all animations as array of objects. * * @method Phaser.Animations.AnimationManager#toJSON * @since 3.0.0 * * @param {string} [key] - The animation to get the JSONAnimation data from. If not provided, all animations are returned as an array. * * @return {Phaser.Types.Animations.JSONAnimations} The resulting JSONAnimations formatted object. */ toJSON: function (key) { var output = { anims: [], globalTimeScale: this.globalTimeScale }; if (key !== undefined && key !== '') { output.anims.push(this.anims.get(key).toJSON()); } else { this.anims.each(function (animationKey, animation) { output.anims.push(animation.toJSON()); }); } return output; }, /** * Destroy this Animation Manager and clean up animation definitions and references to other objects. * This method should not be called directly. It will be called automatically as a response to a `destroy` event from the Phaser.Game instance. * * @method Phaser.Animations.AnimationManager#destroy * @since 3.0.0 */ destroy: function () { this.anims.clear(); this.mixes.clear(); this.textureManager = null; this.game = null; } }); module.exports = AnimationManager; /***/ }), /***/ 9674: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Animation = __webpack_require__(42099); var Between = __webpack_require__(30976); var Class = __webpack_require__(83419); var CustomMap = __webpack_require__(90330); var Events = __webpack_require__(74943); var GetFastValue = __webpack_require__(95540); /** * @classdesc * The Animation State Component. * * This component provides features to apply animations to Game Objects. It is responsible for * loading, queuing animations for later playback, mixing between animations and setting * the current animation frame to the Game Object that owns this component. * * This component lives as an instance within any Game Object that has it defined, such as Sprites. * * You can access its properties and methods via the `anims` property, i.e. `Sprite.anims`. * * As well as playing animations stored in the global Animation Manager, this component * can also create animations that are stored locally within it. See the `create` method * for more details. * * Prior to Phaser 3.50 this component was called just `Animation` and lived in the * `Phaser.GameObjects.Components` namespace. It was renamed to `AnimationState` * in 3.50 to help better identify its true purpose when browsing the documentation. * * @class AnimationState * @memberof Phaser.Animations * @constructor * @since 3.0.0 * * @param {Phaser.GameObjects.GameObject} parent - The Game Object to which this animation component belongs. */ var AnimationState = new Class({ initialize: function AnimationState (parent) { /** * The Game Object to which this animation component belongs. * * You can typically access this component from the Game Object * via the `this.anims` property. * * @name Phaser.Animations.AnimationState#parent * @type {Phaser.GameObjects.GameObject} * @since 3.0.0 */ this.parent = parent; /** * A reference to the global Animation Manager. * * @name Phaser.Animations.AnimationState#animationManager * @type {Phaser.Animations.AnimationManager} * @since 3.0.0 */ this.animationManager = parent.scene.sys.anims; this.animationManager.on(Events.REMOVE_ANIMATION, this.globalRemove, this); /** * A reference to the Texture Manager. * * @name Phaser.Animations.AnimationState#textureManager * @type {Phaser.Textures.TextureManager} * @protected * @since 3.50.0 */ this.textureManager = this.animationManager.textureManager; /** * The Animations stored locally in this Animation component. * * Do not modify the contents of this Map directly, instead use the * `add`, `create` and `remove` methods of this class instead. * * @name Phaser.Animations.AnimationState#anims * @type {Phaser.Structs.Map.} * @protected * @since 3.50.0 */ this.anims = null; /** * Is an animation currently playing or not? * * @name Phaser.Animations.AnimationState#isPlaying * @type {boolean} * @default false * @since 3.0.0 */ this.isPlaying = false; /** * Has the current animation started playing, or is it waiting for a delay to expire? * * @name Phaser.Animations.AnimationState#hasStarted * @type {boolean} * @default false * @since 3.50.0 */ this.hasStarted = false; /** * The current Animation loaded into this Animation component. * * Will by `null` if no animation is yet loaded. * * @name Phaser.Animations.AnimationState#currentAnim * @type {?Phaser.Animations.Animation} * @default null * @since 3.0.0 */ this.currentAnim = null; /** * The current AnimationFrame being displayed by this Animation component. * * Will by `null` if no animation is yet loaded. * * @name Phaser.Animations.AnimationState#currentFrame * @type {?Phaser.Animations.AnimationFrame} * @default null * @since 3.0.0 */ this.currentFrame = null; /** * The key, instance, or config of the next Animation to be loaded into this Animation component * when the current animation completes. * * Will by `null` if no animation has been queued. * * @name Phaser.Animations.AnimationState#nextAnim * @type {?(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig)} * @default null * @since 3.16.0 */ this.nextAnim = null; /** * A queue of Animations to be loaded into this Animation component when the current animation completes. * * Populate this queue via the `chain` method. * * @name Phaser.Animations.AnimationState#nextAnimsQueue * @type {array} * @since 3.24.0 */ this.nextAnimsQueue = []; /** * The Time Scale factor. * * You can adjust this value to modify the passage of time for the animation that is currently * playing. For example, setting it to 2 will make the animation play twice as fast. Or setting * it to 0.5 will slow the animation down. * * You can change this value at run-time, or set it via the `PlayAnimationConfig`. * * Prior to Phaser 3.50 this property was private and called `_timeScale`. * * @name Phaser.Animations.AnimationState#timeScale * @type {number} * @default 1 * @since 3.50.0 */ this.timeScale = 1; /** * The frame rate of playback, of the current animation, in frames per second. * * This value is set when a new animation is loaded into this component and should * be treated as read-only, as changing it once playback has started will not alter * the animation. To change the frame rate, provide a new value in the `PlayAnimationConfig` object. * * @name Phaser.Animations.AnimationState#frameRate * @type {number} * @default 0 * @since 3.0.0 */ this.frameRate = 0; /** * The duration of the current animation, in milliseconds. * * This value is set when a new animation is loaded into this component and should * be treated as read-only, as changing it once playback has started will not alter * the animation. To change the duration, provide a new value in the `PlayAnimationConfig` object. * * @name Phaser.Animations.AnimationState#duration * @type {number} * @default 0 * @since 3.0.0 */ this.duration = 0; /** * The number of milliseconds per frame, not including frame specific modifiers that may be present in the * Animation data. * * This value is calculated when a new animation is loaded into this component and should * be treated as read-only. Changing it will not alter playback speed. * * @name Phaser.Animations.AnimationState#msPerFrame * @type {number} * @default 0 * @since 3.0.0 */ this.msPerFrame = 0; /** * Skip frames if the time lags, or always advanced anyway? * * @name Phaser.Animations.AnimationState#skipMissedFrames * @type {boolean} * @default true * @since 3.0.0 */ this.skipMissedFrames = true; /** * Start playback of this animation from a random frame? * * @name Phaser.Animations.AnimationState#randomFrame * @type {boolean} * @default false * @since 3.60.0 */ this.randomFrame = false; /** * The delay before starting playback of the current animation, in milliseconds. * * This value is set when a new animation is loaded into this component and should * be treated as read-only, as changing it once playback has started will not alter * the animation. To change the delay, provide a new value in the `PlayAnimationConfig` object. * * Prior to Phaser 3.50 this property was private and called `_delay`. * * @name Phaser.Animations.AnimationState#delay * @type {number} * @default 0 * @since 3.50.0 */ this.delay = 0; /** * The number of times to repeat playback of the current animation. * * If -1, it means the animation will repeat forever. * * This value is set when a new animation is loaded into this component and should * be treated as read-only, as changing it once playback has started will not alter * the animation. To change the number of repeats, provide a new value in the `PlayAnimationConfig` object. * * Prior to Phaser 3.50 this property was private and called `_repeat`. * * @name Phaser.Animations.AnimationState#repeat * @type {number} * @default 0 * @since 3.50.0 */ this.repeat = 0; /** * The number of milliseconds to wait before starting the repeat playback of the current animation. * * This value is set when a new animation is loaded into this component, but can also be modified * at run-time. * * You can change the repeat delay by providing a new value in the `PlayAnimationConfig` object. * * Prior to Phaser 3.50 this property was private and called `_repeatDelay`. * * @name Phaser.Animations.AnimationState#repeatDelay * @type {number} * @default 0 * @since 3.0.0 */ this.repeatDelay = 0; /** * Should the current animation yoyo? An animation that yoyos will play in reverse, from the end * to the start, before then repeating or completing. An animation that does not yoyo will just * play from the start to the end. * * This value is set when a new animation is loaded into this component, but can also be modified * at run-time. * * You can change the yoyo by providing a new value in the `PlayAnimationConfig` object. * * Prior to Phaser 3.50 this property was private and called `_yoyo`. * * @name Phaser.Animations.AnimationState#yoyo * @type {boolean} * @default false * @since 3.50.0 */ this.yoyo = false; /** * If the animation has a delay set, before playback will begin, this * controls when the first frame is set on the Sprite. If this property * is 'false' then the frame is set only after the delay has expired. * This is the default behavior. * * If this property is 'true' then the first frame of this animation * is set immediately, and then when the delay expires, playback starts. * * @name Phaser.Animations.AnimationState#showBeforeDelay * @type {boolean} * @since 3.60.0 */ this.showBeforeDelay = false; /** * Should the GameObject's `visible` property be set to `true` when the animation starts to play? * * This will happen _after_ any delay that may have been set. * * This value is set when a new animation is loaded into this component, but can also be modified * at run-time, assuming the animation is currently delayed. * * @name Phaser.Animations.AnimationState#showOnStart * @type {boolean} * @since 3.50.0 */ this.showOnStart = false; /** * Should the GameObject's `visible` property be set to `false` when the animation completes? * * This value is set when a new animation is loaded into this component, but can also be modified * at run-time, assuming the animation is still actively playing. * * @name Phaser.Animations.AnimationState#hideOnComplete * @type {boolean} * @since 3.50.0 */ this.hideOnComplete = false; /** * Is the playhead moving forwards (`true`) or in reverse (`false`) ? * * @name Phaser.Animations.AnimationState#forward * @type {boolean} * @default true * @since 3.0.0 */ this.forward = true; /** * An internal trigger that tells the component if it should plays the animation * in reverse mode ('true') or not ('false'). This is used because `forward` can * be changed by the `yoyo` feature. * * Prior to Phaser 3.50 this property was private and called `_reverse`. * * @name Phaser.Animations.AnimationState#inReverse * @type {boolean} * @default false * @since 3.50.0 */ this.inReverse = false; /** * Internal time overflow accumulator. * * This has the `delta` time added to it as part of the `update` step. * * @name Phaser.Animations.AnimationState#accumulator * @type {number} * @default 0 * @since 3.0.0 */ this.accumulator = 0; /** * The time point at which the next animation frame will change. * * This value is compared against the `accumulator` as part of the `update` step. * * @name Phaser.Animations.AnimationState#nextTick * @type {number} * @default 0 * @since 3.0.0 */ this.nextTick = 0; /** * A counter keeping track of how much delay time, in milliseconds, is left before playback begins. * * This is set via the `playAfterDelay` method, although it can be modified at run-time * if required, as long as the animation has not already started playing. * * @name Phaser.Animations.AnimationState#delayCounter * @type {number} * @default 0 * @since 3.50.0 */ this.delayCounter = 0; /** * A counter that keeps track of how many repeats are left to run. * * This value is set when a new animation is loaded into this component, but can also be modified * at run-time. * * @name Phaser.Animations.AnimationState#repeatCounter * @type {number} * @default 0 * @since 3.0.0 */ this.repeatCounter = 0; /** * An internal flag keeping track of pending repeats. * * @name Phaser.Animations.AnimationState#pendingRepeat * @type {boolean} * @default false * @since 3.0.0 */ this.pendingRepeat = false; /** * Is the Animation paused? * * @name Phaser.Animations.AnimationState#_paused * @type {boolean} * @private * @default false * @since 3.0.0 */ this._paused = false; /** * Was the animation previously playing before being paused? * * @name Phaser.Animations.AnimationState#_wasPlaying * @type {boolean} * @private * @default false * @since 3.0.0 */ this._wasPlaying = false; /** * Internal property tracking if this Animation is waiting to stop. * * 0 = No * 1 = Waiting for ms to pass * 2 = Waiting for repeat * 3 = Waiting for specific frame * * @name Phaser.Animations.AnimationState#_pendingStop * @type {number} * @private * @since 3.4.0 */ this._pendingStop = 0; /** * Internal property used by _pendingStop. * * @name Phaser.Animations.AnimationState#_pendingStopValue * @type {any} * @private * @since 3.4.0 */ this._pendingStopValue; }, /** * Sets an animation, or an array of animations, to be played in the future, after the current one completes or stops. * * The current animation must enter a 'completed' state for this to happen, i.e. finish all of its repeats, delays, etc, * or have one of the `stop` methods called. * * An animation set to repeat forever will never enter a completed state unless stopped. * * You can chain a new animation at any point, including before the current one starts playing, during it, or when it ends (via its `animationcomplete` event). * * Chained animations are specific to a Game Object, meaning different Game Objects can have different chained animations without impacting the global animation they're playing. * * Call this method with no arguments to reset all currently chained animations. * * @method Phaser.Animations.AnimationState#chain * @since 3.16.0 * * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig|string[]|Phaser.Animations.Animation[]|Phaser.Types.Animations.PlayAnimationConfig[])} [key] - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object, or an array of them. * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ chain: function (key) { var parent = this.parent; if (key === undefined) { this.nextAnimsQueue.length = 0; this.nextAnim = null; return parent; } if (!Array.isArray(key)) { key = [ key ]; } for (var i = 0; i < key.length; i++) { var anim = key[i]; if (!this.nextAnim) { this.nextAnim = anim; } else { this.nextAnimsQueue.push(anim); } } return this.parent; }, /** * Returns the key of the animation currently loaded into this component. * * Prior to Phaser 3.50 this method was called `getCurrentKey`. * * @method Phaser.Animations.AnimationState#getName * @since 3.50.0 * * @return {string} The key of the Animation currently loaded into this component, or an empty string if none loaded. */ getName: function () { return (this.currentAnim) ? this.currentAnim.key : ''; }, /** * Returns the key of the animation frame currently displayed by this component. * * @method Phaser.Animations.AnimationState#getFrameName * @since 3.50.0 * * @return {string} The key of the Animation Frame currently displayed by this component, or an empty string if no animation has been loaded. */ getFrameName: function () { return (this.currentFrame) ? this.currentFrame.textureFrame : ''; }, /** * Internal method used to load an animation into this component. * * @method Phaser.Animations.AnimationState#load * @protected * @since 3.0.0 * * @param {(string|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or a `PlayAnimationConfig` object. * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ load: function (key) { if (this.isPlaying) { this.stop(); } var manager = this.animationManager; var animKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', null); // Get the animation, first from the local map and, if not found, from the Animation Manager var anim = (this.exists(animKey)) ? this.get(animKey) : manager.get(animKey); if (!anim) { console.warn('Missing animation: ' + animKey); } else { this.currentAnim = anim; // And now override the animation values, if set in the config. var totalFrames = anim.getTotalFrames(); var frameRate = GetFastValue(key, 'frameRate', anim.frameRate); var duration = GetFastValue(key, 'duration', anim.duration); anim.calculateDuration(this, totalFrames, duration, frameRate); this.delay = GetFastValue(key, 'delay', anim.delay); this.repeat = GetFastValue(key, 'repeat', anim.repeat); this.repeatDelay = GetFastValue(key, 'repeatDelay', anim.repeatDelay); this.yoyo = GetFastValue(key, 'yoyo', anim.yoyo); this.showBeforeDelay = GetFastValue(key, 'showBeforeDelay', anim.showBeforeDelay); this.showOnStart = GetFastValue(key, 'showOnStart', anim.showOnStart); this.hideOnComplete = GetFastValue(key, 'hideOnComplete', anim.hideOnComplete); this.skipMissedFrames = GetFastValue(key, 'skipMissedFrames', anim.skipMissedFrames); this.randomFrame = GetFastValue(key, 'randomFrame', anim.randomFrame); this.timeScale = GetFastValue(key, 'timeScale', this.timeScale); var startFrame = GetFastValue(key, 'startFrame', 0); if (startFrame > totalFrames) { startFrame = 0; } if (this.randomFrame) { startFrame = Between(0, totalFrames - 1); } var frame = anim.frames[startFrame]; if (startFrame === 0 && !this.forward) { frame = anim.getLastFrame(); } this.currentFrame = frame; } return this.parent; }, /** * Pause the current animation and set the `isPlaying` property to `false`. * You can optionally pause it at a specific frame. * * @method Phaser.Animations.AnimationState#pause * @since 3.0.0 * * @param {Phaser.Animations.AnimationFrame} [atFrame] - An optional frame to set after pausing the animation. * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ pause: function (atFrame) { if (!this._paused) { this._paused = true; this._wasPlaying = this.isPlaying; this.isPlaying = false; } if (atFrame !== undefined) { this.setCurrentFrame(atFrame); } return this.parent; }, /** * Resumes playback of a paused animation and sets the `isPlaying` property to `true`. * You can optionally tell it to start playback from a specific frame. * * @method Phaser.Animations.AnimationState#resume * @since 3.0.0 * * @param {Phaser.Animations.AnimationFrame} [fromFrame] - An optional frame to set before restarting playback. * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ resume: function (fromFrame) { if (this._paused) { this._paused = false; this.isPlaying = this._wasPlaying; } if (fromFrame !== undefined) { this.setCurrentFrame(fromFrame); } return this.parent; }, /** * Waits for the specified delay, in milliseconds, then starts playback of the given animation. * * If the animation _also_ has a delay value set in its config, it will be **added** to the delay given here. * * If an animation is already running and a new animation is given to this method, it will wait for * the given delay before starting the new animation. * * If no animation is currently running, the given one begins after the delay. * * Prior to Phaser 3.50 this method was called 'delayedPlay' and the parameters were in the reverse order. * * @method Phaser.Animations.AnimationState#playAfterDelay * @fires Phaser.Animations.Events#ANIMATION_START * @since 3.50.0 * * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. * @param {number} delay - The delay, in milliseconds, to wait before starting the animation playing. * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ playAfterDelay: function (key, delay) { if (!this.isPlaying) { this.delayCounter = delay; this.play(key, true); } else { // If we've got a nextAnim, move it to the queue var nextAnim = this.nextAnim; var queue = this.nextAnimsQueue; if (nextAnim) { queue.unshift(nextAnim); } this.nextAnim = key; this._pendingStop = 1; this._pendingStopValue = delay; } return this.parent; }, /** * Waits for the current animation to complete the `repeatCount` number of repeat cycles, then starts playback * of the given animation. * * You can use this to ensure there are no harsh jumps between two sets of animations, i.e. going from an * idle animation to a walking animation, by making them blend smoothly into each other. * * If no animation is currently running, the given one will start immediately. * * @method Phaser.Animations.AnimationState#playAfterRepeat * @fires Phaser.Animations.Events#ANIMATION_START * @since 3.50.0 * * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. * @param {number} [repeatCount=1] - How many times should the animation repeat before the next one starts? * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ playAfterRepeat: function (key, repeatCount) { if (repeatCount === undefined) { repeatCount = 1; } if (!this.isPlaying) { this.play(key); } else { // If we've got a nextAnim, move it to the queue var nextAnim = this.nextAnim; var queue = this.nextAnimsQueue; if (nextAnim) { queue.unshift(nextAnim); } if (this.repeatCounter !== -1 && repeatCount > this.repeatCounter) { repeatCount = this.repeatCounter; } this.nextAnim = key; this._pendingStop = 2; this._pendingStopValue = repeatCount; } return this.parent; }, /** * Start playing the given animation on this Sprite. * * Animations in Phaser can either belong to the global Animation Manager, or specifically to this Sprite. * * The benefit of a global animation is that multiple Sprites can all play the same animation, without * having to duplicate the data. You can just create it once and then play it on any Sprite. * * The following code shows how to create a global repeating animation. The animation will be created * from all of the frames within the sprite sheet that was loaded with the key 'muybridge': * * ```javascript * var config = { * key: 'run', * frames: 'muybridge', * frameRate: 15, * repeat: -1 * }; * * // This code should be run from within a Scene: * this.anims.create(config); * ``` * * However, if you wish to create an animation that is unique to this Sprite, and this Sprite alone, * you can call the `Animation.create` method instead. It accepts the exact same parameters as when * creating a global animation, however the resulting data is kept locally in this Sprite. * * With the animation created, either globally or locally, you can now play it on this Sprite: * * ```javascript * this.add.sprite(x, y).play('run'); * ``` * * Alternatively, if you wish to run it at a different frame rate, for example, you can pass a config * object instead: * * ```javascript * this.add.sprite(x, y).play({ key: 'run', frameRate: 24 }); * ``` * * When playing an animation on a Sprite it will first check to see if it can find a matching key * locally within the Sprite. If it can, it will play the local animation. If not, it will then * search the global Animation Manager and look for it there. * * If you need a Sprite to be able to play both local and global animations, make sure they don't * have conflicting keys. * * See the documentation for the `PlayAnimationConfig` config object for more details about this. * * Also, see the documentation in the Animation Manager for further details on creating animations. * * @method Phaser.Animations.AnimationState#play * @fires Phaser.Animations.Events#ANIMATION_START * @since 3.0.0 * * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. * @param {boolean} [ignoreIfPlaying=false] - If this animation is already playing then ignore this call. * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ play: function (key, ignoreIfPlaying) { if (ignoreIfPlaying === undefined) { ignoreIfPlaying = false; } var currentAnim = this.currentAnim; var parent = this.parent; // Must be either an Animation instance, or a PlayAnimationConfig object var animKey = (typeof key === 'string') ? key : key.key; if (ignoreIfPlaying && this.isPlaying && currentAnim.key === animKey) { return parent; } // Are we mixing? if (currentAnim && this.isPlaying) { var mix = this.animationManager.getMix(currentAnim.key, key); if (mix > 0) { return this.playAfterDelay(key, mix); } } this.forward = true; this.inReverse = false; this._paused = false; this._wasPlaying = true; return this.startAnimation(key); }, /** * Start playing the given animation on this Sprite, in reverse. * * Animations in Phaser can either belong to the global Animation Manager, or specifically to this Sprite. * * The benefit of a global animation is that multiple Sprites can all play the same animation, without * having to duplicate the data. You can just create it once and then play it on any Sprite. * * The following code shows how to create a global repeating animation. The animation will be created * from all of the frames within the sprite sheet that was loaded with the key 'muybridge': * * ```javascript * var config = { * key: 'run', * frames: 'muybridge', * frameRate: 15, * repeat: -1 * }; * * // This code should be run from within a Scene: * this.anims.create(config); * ``` * * However, if you wish to create an animation that is unique to this Sprite, and this Sprite alone, * you can call the `Animation.create` method instead. It accepts the exact same parameters as when * creating a global animation, however the resulting data is kept locally in this Sprite. * * With the animation created, either globally or locally, you can now play it on this Sprite: * * ```javascript * this.add.sprite(x, y).playReverse('run'); * ``` * * Alternatively, if you wish to run it at a different frame rate, for example, you can pass a config * object instead: * * ```javascript * this.add.sprite(x, y).playReverse({ key: 'run', frameRate: 24 }); * ``` * * When playing an animation on a Sprite it will first check to see if it can find a matching key * locally within the Sprite. If it can, it will play the local animation. If not, it will then * search the global Animation Manager and look for it there. * * If you need a Sprite to be able to play both local and global animations, make sure they don't * have conflicting keys. * * See the documentation for the `PlayAnimationConfig` config object for more details about this. * * Also, see the documentation in the Animation Manager for further details on creating animations. * * @method Phaser.Animations.AnimationState#playReverse * @fires Phaser.Animations.Events#ANIMATION_START * @since 3.12.0 * * @param {(string|Phaser.Animations.Animation|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or an Animation instance, or a `PlayAnimationConfig` object. * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ playReverse: function (key, ignoreIfPlaying) { if (ignoreIfPlaying === undefined) { ignoreIfPlaying = false; } // Must be either an Animation instance, or a PlayAnimationConfig object var animKey = (typeof key === 'string') ? key : key.key; if (ignoreIfPlaying && this.isPlaying && this.currentAnim.key === animKey) { return this.parent; } this.forward = false; this.inReverse = true; this._paused = false; this._wasPlaying = true; return this.startAnimation(key); }, /** * Load the animation based on the key and set-up all of the internal values * needed for playback to start. If there is no delay, it will also fire the start events. * * @method Phaser.Animations.AnimationState#startAnimation * @fires Phaser.Animations.Events#ANIMATION_START * @since 3.50.0 * * @param {(string|Phaser.Types.Animations.PlayAnimationConfig)} key - The string-based key of the animation to play, or a `PlayAnimationConfig` object. * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ startAnimation: function (key) { this.load(key); var anim = this.currentAnim; var gameObject = this.parent; if (!anim) { return gameObject; } // 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.isPlaying = true; this.pendingRepeat = false; this.hasStarted = false; this._pendingStop = 0; this._pendingStopValue = 0; this._paused = false; // Add any delay the animation itself may have had as well this.delayCounter += this.delay; if (this.delayCounter === 0) { this.handleStart(); } else if (this.showBeforeDelay) { // We have a delay, but still need to set the frame this.setCurrentFrame(this.currentFrame); } return gameObject; }, /** * Handles the start of an animation playback. * * @method Phaser.Animations.AnimationState#handleStart * @private * @since 3.50.0 */ handleStart: function () { if (this.showOnStart) { this.parent.setVisible(true); } this.setCurrentFrame(this.currentFrame); this.hasStarted = true; this.emitEvents(Events.ANIMATION_START); }, /** * Handles the repeat of an animation. * * @method Phaser.Animations.AnimationState#handleRepeat * @private * @since 3.50.0 */ handleRepeat: function () { this.pendingRepeat = false; this.emitEvents(Events.ANIMATION_REPEAT); }, /** * Handles the stop of an animation playback. * * @method Phaser.Animations.AnimationState#handleStop * @private * @since 3.50.0 */ handleStop: function () { this._pendingStop = 0; this.isPlaying = false; this.emitEvents(Events.ANIMATION_STOP); }, /** * Handles the completion of an animation playback. * * @method Phaser.Animations.AnimationState#handleComplete * @private * @since 3.50.0 */ handleComplete: function () { this._pendingStop = 0; this.isPlaying = false; if (this.hideOnComplete) { this.parent.setVisible(false); } this.emitEvents(Events.ANIMATION_COMPLETE, Events.ANIMATION_COMPLETE_KEY); }, /** * Fires the given animation event. * * @method Phaser.Animations.AnimationState#emitEvents * @private * @since 3.50.0 * * @param {string} event - The Animation Event to dispatch. */ emitEvents: function (event, keyEvent) { var anim = this.currentAnim; if (anim) { var frame = this.currentFrame; var gameObject = this.parent; var frameKey = frame.textureFrame; gameObject.emit(event, anim, frame, gameObject, frameKey); if (keyEvent) { gameObject.emit(keyEvent + anim.key, anim, frame, gameObject, frameKey); } } }, /** * Reverse the Animation that is already playing on the Game Object. * * @method Phaser.Animations.AnimationState#reverse * @since 3.12.0 * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ reverse: function () { if (this.isPlaying) { this.inReverse = !this.inReverse; this.forward = !this.forward; } return this.parent; }, /** * Returns a value between 0 and 1 indicating how far this animation is through, ignoring repeats and yoyos. * * The value is based on the current frame and how far that is in the animation, it is not based on * the duration of the animation. * * @method Phaser.Animations.AnimationState#getProgress * @since 3.4.0 * * @return {number} The progress of the current animation in frames, between 0 and 1. */ getProgress: function () { var frame = this.currentFrame; if (!frame) { return 0; } var p = frame.progress; if (this.inReverse) { p *= -1; } return p; }, /** * Takes a value between 0 and 1 and uses it to set how far this animation is through playback. * * Does not factor in repeats or yoyos, but does handle playing forwards or backwards. * * The value is based on the current frame and how far that is in the animation, it is not based on * the duration of the animation. * * @method Phaser.Animations.AnimationState#setProgress * @since 3.4.0 * * @param {number} [value=0] - The progress value, between 0 and 1. * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ setProgress: function (value) { if (!this.forward) { value = 1 - value; } this.setCurrentFrame(this.currentAnim.getFrameByProgress(value)); return this.parent; }, /** * Sets the number of times that the animation should repeat after its first play through. * 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. * The value should always be an integer. * * Calling this method only works if the animation is already running. Otherwise, any * value specified here will be overwritten when the next animation loads in. To avoid this, * use the `repeat` property of the `PlayAnimationConfig` object instead. * * @method Phaser.Animations.AnimationState#setRepeat * @since 3.4.0 * * @param {number} value - The number of times that the animation should repeat. * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ setRepeat: function (value) { this.repeatCounter = (value === -1) ? Number.MAX_VALUE : value; return this.parent; }, /** * Handle the removal of an animation from the Animation Manager. * * @method Phaser.Animations.AnimationState#globalRemove * @since 3.50.0 * * @param {string} [key] - The key of the removed Animation. * @param {Phaser.Animations.Animation} [animation] - The removed Animation. */ globalRemove: function (key, animation) { if (animation === undefined) { animation = this.currentAnim; } if (this.isPlaying && animation.key === this.currentAnim.key) { this.stop(); this.setCurrentFrame(this.currentAnim.frames[0]); } }, /** * Restarts the current animation from its beginning. * * You can optionally reset the delay and repeat counters as well. * * Calling this will fire the `ANIMATION_RESTART` event immediately. * * If you `includeDelay` then it will also fire the `ANIMATION_START` event once * the delay has expired, otherwise, playback will just begin immediately. * * @method Phaser.Animations.AnimationState#restart * @fires Phaser.Animations.Events#ANIMATION_RESTART * @since 3.0.0 * * @param {boolean} [includeDelay=false] - Whether to include the delay value of the animation when restarting. * @param {boolean} [resetRepeats=false] - Whether to reset the repeat counter or not? * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ restart: function (includeDelay, resetRepeats) { if (includeDelay === undefined) { includeDelay = false; } if (resetRepeats === undefined) { resetRepeats = false; } var anim = this.currentAnim; var gameObject = this.parent; if (!anim) { return gameObject; } if (resetRepeats) { this.repeatCounter = (this.repeat === -1) ? Number.MAX_VALUE : this.repeat; } anim.getFirstTick(this); this.emitEvents(Events.ANIMATION_RESTART); this.isPlaying = true; this.pendingRepeat = false; // Set this to `true` if there is no delay to include, so it skips the `hasStarted` check in `update`. this.hasStarted = !includeDelay; this._pendingStop = 0; this._pendingStopValue = 0; this._paused = false; this.setCurrentFrame(anim.frames[0]); return this.parent; }, /** * The current animation has completed. This dispatches the `ANIMATION_COMPLETE` event. * * This method is called by the Animation instance and should not usually be invoked directly. * * If no animation is loaded, no events will be dispatched. * * If another animation has been queued for playback, it will be started after the events fire. * * @method Phaser.Animations.AnimationState#complete * @fires Phaser.Animations.Events#ANIMATION_COMPLETE * @since 3.50.0 * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ complete: function () { this._pendingStop = 0; this.isPlaying = false; if (this.currentAnim) { this.handleComplete(); } if (this.nextAnim) { var key = this.nextAnim; this.nextAnim = (this.nextAnimsQueue.length > 0) ? this.nextAnimsQueue.shift() : null; this.play(key); } return this.parent; }, /** * Immediately stops the current animation from playing and dispatches the `ANIMATION_STOP` event. * * If no animation is running, no events will be dispatched. * * If there is another animation in the queue (set via the `chain` method) then it will start playing. * * @method Phaser.Animations.AnimationState#stop * @fires Phaser.Animations.Events#ANIMATION_STOP * @since 3.0.0 * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ stop: function () { this._pendingStop = 0; this.isPlaying = false; this.delayCounter = 0; if (this.currentAnim) { this.handleStop(); } if (this.nextAnim) { var key = this.nextAnim; this.nextAnim = this.nextAnimsQueue.shift(); this.play(key); } return this.parent; }, /** * Stops the current animation from playing after the specified time delay, given in milliseconds. * * It then dispatches the `ANIMATION_STOP` event. * * If no animation is running, no events will be dispatched. * * If there is another animation in the queue (set via the `chain` method) then it will start playing, * when the current one stops. * * @method Phaser.Animations.AnimationState#stopAfterDelay * @fires Phaser.Animations.Events#ANIMATION_STOP * @since 3.4.0 * * @param {number} delay - The number of milliseconds to wait before stopping this animation. * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ stopAfterDelay: function (delay) { this._pendingStop = 1; this._pendingStopValue = delay; return this.parent; }, /** * Stops the current animation from playing when it next repeats. * * It then dispatches the `ANIMATION_STOP` event. * * If no animation is running, no events will be dispatched. * * If there is another animation in the queue (set via the `chain` method) then it will start playing, * when the current one stops. * * Prior to Phaser 3.50 this method was called `stopOnRepeat` and had no parameters. * * @method Phaser.Animations.AnimationState#stopAfterRepeat * @fires Phaser.Animations.Events#ANIMATION_STOP * @since 3.50.0 * * @param {number} [repeatCount=1] - How many times should the animation repeat before stopping? * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ stopAfterRepeat: function (repeatCount) { if (repeatCount === undefined) { repeatCount = 1; } if (this.repeatCounter !== -1 && repeatCount > this.repeatCounter) { repeatCount = this.repeatCounter; } this._pendingStop = 2; this._pendingStopValue = repeatCount; return this.parent; }, /** * Stops the current animation from playing when it next sets the given frame. * If this frame doesn't exist within the animation it will not stop it from playing. * * It then dispatches the `ANIMATION_STOP` event. * * If no animation is running, no events will be dispatched. * * If there is another animation in the queue (set via the `chain` method) then it will start playing, * when the current one stops. * * @method Phaser.Animations.AnimationState#stopOnFrame * @fires Phaser.Animations.Events#ANIMATION_STOP * @since 3.4.0 * * @param {Phaser.Animations.AnimationFrame} frame - The frame to check before stopping this animation. * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ stopOnFrame: function (frame) { this._pendingStop = 3; this._pendingStopValue = frame; return this.parent; }, /** * Returns the total number of frames in this animation, or returns zero if no * animation has been loaded. * * @method Phaser.Animations.AnimationState#getTotalFrames * @since 3.4.0 * * @return {number} The total number of frames in the current animation, or zero if no animation has been loaded. */ getTotalFrames: function () { return (this.currentAnim) ? this.currentAnim.getTotalFrames() : 0; }, /** * The internal update loop for the AnimationState Component. * * This is called automatically by the `Sprite.preUpdate` method. * * @method Phaser.Animations.AnimationState#update * @since 3.0.0 * * @param {number} time - The current timestamp. * @param {number} delta - The delta time, in ms, elapsed since the last frame. */ update: function (time, delta) { var anim = this.currentAnim; if (!this.isPlaying || !anim || anim.paused) { return; } this.accumulator += delta * this.timeScale * this.animationManager.globalTimeScale; if (this._pendingStop === 1) { this._pendingStopValue -= delta; if (this._pendingStopValue <= 0) { return this.stop(); } } if (!this.hasStarted) { if (this.accumulator >= this.delayCounter) { this.accumulator -= this.delayCounter; this.handleStart(); } } else if (this.accumulator >= this.nextTick) { // Process one frame advance as standard if (this.forward) { anim.nextFrame(this); } else { anim.previousFrame(this); } // And only do more if we're skipping frames and have time left if (this.isPlaying && this._pendingStop === 0 && this.skipMissedFrames && this.accumulator > this.nextTick) { var safetyNet = 0; do { if (this.forward) { anim.nextFrame(this); } else { anim.previousFrame(this); } safetyNet++; } while (this.isPlaying && this.accumulator > this.nextTick && safetyNet < 60); } } }, /** * Sets the given Animation Frame as being the current frame * and applies it to the parent Game Object, adjusting size and origin as needed. * * @method Phaser.Animations.AnimationState#setCurrentFrame * @fires Phaser.Animations.Events#ANIMATION_UPDATE * @fires Phaser.Animations.Events#ANIMATION_STOP * @since 3.4.0 * * @param {Phaser.Animations.AnimationFrame} animationFrame - The animation frame to change to. * * @return {Phaser.GameObjects.GameObject} The Game Object this Animation Component belongs to. */ setCurrentFrame: function (animationFrame) { var gameObject = this.parent; this.currentFrame = animationFrame; gameObject.texture = animationFrame.frame.texture; gameObject.frame = animationFrame.frame; if (gameObject.isCropped) { gameObject.frame.updateCropUVs(gameObject._crop, gameObject.flipX, gameObject.flipY); } if (animationFrame.setAlpha) { gameObject.alpha = animationFrame.alpha; } gameObject.setSizeToFrame(); if (gameObject._originComponent) { if (animationFrame.frame.customPivot) { gameObject.setOrigin(animationFrame.frame.pivotX, animationFrame.frame.pivotY); } else { gameObject.updateDisplayOrigin(); } } if (this.isPlaying && this.hasStarted) { this.emitEvents(Events.ANIMATION_UPDATE); if (this._pendingStop === 3 && this._pendingStopValue === animationFrame) { this.stop(); } } return gameObject; }, /** * Advances the animation to the next frame, regardless of the time or animation state. * If the animation is set to repeat, or yoyo, this will still take effect. * * Calling this does not change the direction of the animation. I.e. if it was currently * playing in reverse, calling this method doesn't then change the direction to forwards. * * @method Phaser.Animations.AnimationState#nextFrame * @since 3.16.0 * * @return {Phaser.GameObjects.GameObject} The Game Object this Animation Component belongs to. */ nextFrame: function () { if (this.currentAnim) { this.currentAnim.nextFrame(this); } return this.parent; }, /** * Advances the animation to the previous frame, regardless of the time or animation state. * If the animation is set to repeat, or yoyo, this will still take effect. * * Calling this does not change the direction of the animation. I.e. if it was currently * playing in forwards, calling this method doesn't then change the direction to backwards. * * @method Phaser.Animations.AnimationState#previousFrame * @since 3.16.0 * * @return {Phaser.GameObjects.GameObject} The Game Object this Animation Component belongs to. */ previousFrame: function () { if (this.currentAnim) { this.currentAnim.previousFrame(this); } return this.parent; }, /** * Get an Animation instance that has been created locally on this Sprite. * * See the `create` method for more details. * * @method Phaser.Animations.AnimationState#get * @since 3.50.0 * * @param {string} key - The key of the Animation to retrieve. * * @return {Phaser.Animations.Animation} The Animation, or `null` if the key is invalid. */ get: function (key) { return (this.anims) ? this.anims.get(key) : null; }, /** * Checks to see if the given key is already used locally within the animations stored on this Sprite. * * @method Phaser.Animations.AnimationState#exists * @since 3.50.0 * * @param {string} key - The key of the Animation to check. * * @return {boolean} `true` if the Animation exists locally, or `false` if the key is available, or there are no local animations. */ exists: function (key) { return (this.anims) ? this.anims.has(key) : false; }, /** * Creates a new Animation that is local specifically to this Sprite. * * When a Sprite owns an animation, it is kept out of the global Animation Manager, which means * you're free to use keys that may be already defined there. Unless you specifically need a Sprite * to have a unique animation, you should favor using global animations instead, as they allow for * the same animation to be used across multiple Sprites, saving on memory. However, if this Sprite * is the only one to use this animation, it's sensible to create it here. * * If an invalid key is given this method will return `false`. * * If you pass the key of an animation that already exists locally, that animation will be returned. * * A brand new animation is only created if the key is valid and not already in use by this Sprite. * * If you wish to re-use an existing key, call the `remove` method first, then this method. * * @method Phaser.Animations.AnimationState#create * @since 3.50.0 * * @param {Phaser.Types.Animations.Animation} config - The configuration settings for the Animation. * * @return {(Phaser.Animations.Animation|false)} The Animation that was created, or `false` if the key is already in use. */ create: function (config) { var key = config.key; var anim = false; if (key) { anim = this.get(key); if (!anim) { anim = new Animation(this, key, config); if (!this.anims) { this.anims = new CustomMap(); } this.anims.set(key, anim); } else { console.warn('Animation key already exists: ' + key); } } return anim; }, /** * Create one, or more animations from a loaded Aseprite JSON file. * * Aseprite is a powerful animated sprite editor and pixel art tool. * * You can find more details at https://www.aseprite.org/ * * To export a compatible JSON file in Aseprite, please do the following: * * 1. Go to "File - Export Sprite Sheet" * * 2. On the **Layout** tab: * 2a. Set the "Sheet type" to "Packed" * 2b. Set the "Constraints" to "None" * 2c. Check the "Merge Duplicates" checkbox * * 3. On the **Sprite** tab: * 3a. Set "Layers" to "Visible layers" * 3b. Set "Frames" to "All frames", unless you only wish to export a sub-set of tags * * 4. On the **Borders** tab: * 4a. Check the "Trim Sprite" and "Trim Cells" options * 4b. Ensure "Border Padding", "Spacing" and "Inner Padding" are all > 0 (1 is usually enough) * * 5. On the **Output** tab: * 5a. Check "Output File", give your image a name and make sure you choose "png files" as the file type * 5b. Check "JSON Data" and give your json file a name * 5c. The JSON Data type can be either a Hash or Array, Phaser doesn't mind. * 5d. Make sure "Tags" is checked in the Meta options * 5e. In the "Item Filename" input box, make sure it says just "{frame}" and nothing more. * * 6. Click export * * This was tested with Aseprite 1.2.25. * * This will export a png and json file which you can load using the Aseprite Loader, i.e.: * * ```javascript * function preload () * { * this.load.path = 'assets/animations/aseprite/'; * this.load.aseprite('paladin', 'paladin.png', 'paladin.json'); * } * ``` * * Once loaded, you can call this method on a Sprite with the 'atlas' key: * * ```javascript * const sprite = this.add.sprite(400, 300); * * sprite.anims.createFromAseprite('paladin'); * ``` * * Any animations defined in the JSON will now be available to use on this Sprite and you play them * via their Tag name. For example, if you have an animation called 'War Cry' on your Aseprite timeline, * you can play it on the Sprite using that Tag name: * * ```javascript * const sprite = this.add.sprite(400, 300); * * sprite.anims.createFromAseprite('paladin'); * * sprite.play('War Cry'); * ``` * * When calling this method you can optionally provide an array of tag names, and only those animations * will be created. For example: * * ```javascript * sprite.anims.createFromAseprite('paladin', [ 'step', 'War Cry', 'Magnum Break' ]); * ``` * * This will only create the 3 animations defined. Note that the tag names are case-sensitive. * * @method Phaser.Animations.AnimationState#createFromAseprite * @since 3.60.0 * * @param {string} key - The key of the loaded Aseprite atlas. It must have been loaded prior to calling this method. * @param {string[]} [tags] - An array of Tag names. If provided, only animations found in this array will be created. * * @return {Phaser.Animations.Animation[]} An array of Animation instances that were successfully created. */ createFromAseprite: function (key, tags) { return this.animationManager.createFromAseprite(key, tags, this.parent); }, /** * Generate an array of {@link Phaser.Types.Animations.AnimationFrame} objects from a texture key and configuration object. * * Generates objects with string based frame names, as configured by the given {@link Phaser.Types.Animations.GenerateFrameNames}. * * It's a helper method, designed to make it easier for you to extract all of the frame names from texture atlases. * If you're working with a sprite sheet, see the `generateFrameNumbers` method instead. * * Example: * * If you have a texture atlases loaded called `gems` and it contains 6 frames called `ruby_0001`, `ruby_0002`, and so on, * then you can call this method using: `this.anims.generateFrameNames('gems', { prefix: 'ruby_', end: 6, zeroPad: 4 })`. * * The `end` value tells it to look for 6 frames, incrementally numbered, all starting with the prefix `ruby_`. The `zeroPad` * value tells it how many zeroes pad out the numbers. To create an animation using this method, you can do: * * ```javascript * this.anims.create({ * key: 'ruby', * repeat: -1, * frames: this.anims.generateFrameNames('gems', { * prefix: 'ruby_', * end: 6, * zeroPad: 4 * }) * }); * ``` * * Please see the animation examples for further details. * * @method Phaser.Animations.AnimationState#generateFrameNames * @since 3.50.0 * * @param {string} key - The key for the texture containing the animation frames. * @param {Phaser.Types.Animations.GenerateFrameNames} [config] - The configuration object for the animation frame names. * * @return {Phaser.Types.Animations.AnimationFrame[]} The array of {@link Phaser.Types.Animations.AnimationFrame} objects. */ generateFrameNames: function (key, config) { return this.animationManager.generateFrameNames(key, config); }, /** * Generate an array of {@link Phaser.Types.Animations.AnimationFrame} objects from a texture key and configuration object. * * Generates objects with numbered frame names, as configured by the given {@link Phaser.Types.Animations.GenerateFrameNumbers}. * * If you're working with a texture atlas, see the `generateFrameNames` method instead. * * It's a helper method, designed to make it easier for you to extract frames from sprite sheets. * If you're working with a texture atlas, see the `generateFrameNames` method instead. * * Example: * * If you have a sprite sheet loaded called `explosion` and it contains 12 frames, then you can call this method using: * `this.anims.generateFrameNumbers('explosion', { start: 0, end: 11 })`. * * The `end` value tells it to stop after 12 frames. To create an animation using this method, you can do: * * ```javascript * this.anims.create({ * key: 'boom', * frames: this.anims.generateFrameNumbers('explosion', { * start: 0, * end: 11 * }) * }); * ``` * * Note that `start` is optional and you don't need to include it if the animation starts from frame 0. * * To specify an animation in reverse, swap the `start` and `end` values. * * If the frames are not sequential, you may pass an array of frame numbers instead, for example: * * `this.anims.generateFrameNumbers('explosion', { frames: [ 0, 1, 2, 1, 2, 3, 4, 0, 1, 2 ] })` * * Please see the animation examples and `GenerateFrameNumbers` config docs for further details. * * @method Phaser.Animations.AnimationState#generateFrameNumbers * @since 3.50.0 * * @param {string} key - The key for the texture containing the animation frames. * @param {Phaser.Types.Animations.GenerateFrameNumbers} [config] - The configuration object for the animation frames. * * @return {Phaser.Types.Animations.AnimationFrame[]} The array of {@link Phaser.Types.Animations.AnimationFrame} objects. */ generateFrameNumbers: function (key, config) { return this.animationManager.generateFrameNumbers(key, config); }, /** * Removes a locally created Animation from this Sprite, based on the given key. * * Once an Animation has been removed, this Sprite cannot play it again without re-creating it. * * @method Phaser.Animations.AnimationState#remove * @since 3.50.0 * * @param {string} key - The key of the animation to remove. * * @return {Phaser.Animations.Animation} The Animation instance that was removed from this Sprite, if the key was valid. */ remove: function (key) { var anim = this.get(key); if (anim) { if (this.currentAnim === anim) { this.stop(); } this.anims.delete(key); } return anim; }, /** * Destroy this Animation component. * * Unregisters event listeners and cleans up its references. * * @method Phaser.Animations.AnimationState#destroy * @since 3.0.0 */ destroy: function () { this.animationManager.off(Events.REMOVE_ANIMATION, this.globalRemove, this); if (this.anims) { this.anims.clear(); } this.animationManager = null; this.parent = null; this.nextAnim = null; this.nextAnimsQueue.length = 0; this.currentAnim = null; this.currentFrame = null; }, /** * `true` if the current animation is paused, otherwise `false`. * * @name Phaser.Animations.AnimationState#isPaused * @readonly * @type {boolean} * @since 3.4.0 */ isPaused: { get: function () { return this._paused; } } }); module.exports = AnimationState; /***/ }), /***/ 57090: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Add Animation Event. * * This event is dispatched when a new animation is added to the global Animation Manager. * * This can happen either as a result of an animation instance being added to the Animation Manager, * or the Animation Manager creating a new animation directly. * * @event Phaser.Animations.Events#ADD_ANIMATION * @type {string} * @since 3.0.0 * * @param {string} key - The key of the Animation that was added to the global Animation Manager. * @param {Phaser.Animations.Animation} animation - An instance of the newly created Animation. */ module.exports = 'add'; /***/ }), /***/ 25312: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Animation Complete Event. * * This event is dispatched by a Sprite when an animation playing on it completes playback. * This happens when the animation gets to the end of its sequence, factoring in any delays * or repeats it may have to process. * * An animation that is set to loop, or repeat forever, will never fire this event, because * it never actually completes. If you need to handle this, listen for the `ANIMATION_STOP` * event instead, as this is emitted when the animation is stopped directly. * * Listen for it on the Sprite using `sprite.on('animationcomplete', listener)` * * The animation event flow is as follows: * * 1. `ANIMATION_START` * 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has) * 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this) * 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count) * 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count) * * If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`. * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. * * @event Phaser.Animations.Events#ANIMATION_COMPLETE * @type {string} * @since 3.50.0 * * @param {Phaser.Animations.Animation} animation - A reference to the Animation that completed. * @param {Phaser.Animations.AnimationFrame} frame - The current Animation Frame of the Animation. * @param {Phaser.GameObjects.Sprite} gameObject - A reference to the Game Object on which the animation updated. * @param {string} frameKey - The unique key of the Animation Frame within the Animation. */ module.exports = 'animationcomplete'; /***/ }), /***/ 89580: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Animation Complete Dynamic Key Event. * * This event is dispatched by a Sprite when an animation playing on it completes playback. * This happens when the animation gets to the end of its sequence, factoring in any delays * or repeats it may have to process. * * An animation that is set to loop, or repeat forever, will never fire this event, because * it never actually completes. If you need to handle this, listen for the `ANIMATION_STOP` * event instead, as this is emitted when the animation is stopped directly. * * The difference between this and the `ANIMATION_COMPLETE` event is that this one has a * dynamic event name that contains the name of the animation within it. For example, * if you had an animation called `explode` you could listen for the completion of that * specific animation by using: `sprite.on('animationcomplete-explode', listener)`. Or, if you * wish to use types: `sprite.on(Phaser.Animations.Events.ANIMATION_COMPLETE_KEY + 'explode', listener)`. * * The animation event flow is as follows: * * 1. `ANIMATION_START` * 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has) * 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this) * 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count) * 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count) * * If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`. * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. * * @event Phaser.Animations.Events#ANIMATION_COMPLETE_KEY * @type {string} * @since 3.50.0 * * @param {Phaser.Animations.Animation} animation - A reference to the Animation that completed. * @param {Phaser.Animations.AnimationFrame} frame - The current Animation Frame of the Animation. * @param {Phaser.GameObjects.Sprite} gameObject - A reference to the Game Object on which the animation updated. * @param {string} frameKey - The unique key of the Animation Frame within the Animation. */ module.exports = 'animationcomplete-'; /***/ }), /***/ 52860: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Animation Repeat Event. * * This event is dispatched by a Sprite when an animation repeats playing on it. * This happens if the animation was created, or played, with a `repeat` value specified. * * An animation will repeat when it reaches the end of its sequence. * * Listen for it on the Sprite using `sprite.on('animationrepeat', listener)` * * The animation event flow is as follows: * * 1. `ANIMATION_START` * 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has) * 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this) * 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count) * 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count) * * If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`. * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. * * @event Phaser.Animations.Events#ANIMATION_REPEAT * @type {string} * @since 3.50.0 * * @param {Phaser.Animations.Animation} animation - A reference to the Animation that has repeated. * @param {Phaser.Animations.AnimationFrame} frame - The current Animation Frame of the Animation. * @param {Phaser.GameObjects.Sprite} gameObject - A reference to the Game Object on which the animation repeated. * @param {string} frameKey - The unique key of the Animation Frame within the Animation. */ module.exports = 'animationrepeat'; /***/ }), /***/ 63850: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Animation Restart Event. * * This event is dispatched by a Sprite when an animation restarts playing on it. * This only happens when the `Sprite.anims.restart` method is called. * * Listen for it on the Sprite using `sprite.on('animationrestart', listener)` * * The animation event flow is as follows: * * 1. `ANIMATION_START` * 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has) * 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this) * 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count) * 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count) * * If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`. * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. * * @event Phaser.Animations.Events#ANIMATION_RESTART * @type {string} * @since 3.50.0 * * @param {Phaser.Animations.Animation} animation - A reference to the Animation that has restarted. * @param {Phaser.Animations.AnimationFrame} frame - The current Animation Frame of the Animation. * @param {Phaser.GameObjects.Sprite} gameObject - A reference to the Game Object on which the animation restarted. * @param {string} frameKey - The unique key of the Animation Frame within the Animation. */ module.exports = 'animationrestart'; /***/ }), /***/ 99085: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Animation Start Event. * * This event is dispatched by a Sprite when an animation starts playing on it. * This happens when the animation is played, factoring in any delay that may have been specified. * This event happens after the delay has expired and prior to the first update event. * * Listen for it on the Sprite using `sprite.on('animationstart', listener)` * * The animation event flow is as follows: * * 1. `ANIMATION_START` * 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has) * 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this) * 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count) * 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count) * * If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`. * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. * * @event Phaser.Animations.Events#ANIMATION_START * @type {string} * @since 3.50.0 * * @param {Phaser.Animations.Animation} animation - A reference to the Animation that has started. * @param {Phaser.Animations.AnimationFrame} frame - The current Animation Frame of the Animation. * @param {Phaser.GameObjects.Sprite} gameObject - A reference to the Game Object on which the animation started. * @param {string} frameKey - The unique key of the Animation Frame within the Animation. */ module.exports = 'animationstart'; /***/ }), /***/ 28087: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Animation Stop Event. * * This event is dispatched by a Sprite when an animation is stopped on it. An animation * will only be stopeed if a method such as `Sprite.stop` or `Sprite.anims.stopAfterDelay` * is called. It can also be emitted if a new animation is started before the current one completes. * * Listen for it on the Sprite using `sprite.on('animationstop', listener)` * * The animation event flow is as follows: * * 1. `ANIMATION_START` * 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has) * 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this) * 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count) * 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count) * * If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`. * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. * * @event Phaser.Animations.Events#ANIMATION_STOP * @type {string} * @since 3.50.0 * * @param {Phaser.Animations.Animation} animation - A reference to the Animation that has stopped. * @param {Phaser.Animations.AnimationFrame} frame - The current Animation Frame of the Animation. * @param {Phaser.GameObjects.Sprite} gameObject - A reference to the Game Object on which the animation stopped. * @param {string} frameKey - The unique key of the Animation Frame within the Animation. */ module.exports = 'animationstop'; /***/ }), /***/ 1794: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Animation Update Event. * * This event is dispatched by a Sprite when an animation playing on it updates. This happens when the animation changes frame. * An animation will change frame based on the frame rate and other factors like `timeScale` and `delay`. It can also change * frame when stopped or restarted. * * Listen for it on the Sprite using `sprite.on('animationupdate', listener)` * * If an animation is playing faster than the game frame-rate can handle, it's entirely possible for it to emit several * update events in a single game frame, so please be aware of this in your code. The **final** event received that frame * is the one that is rendered to the game. * * The animation event flow is as follows: * * 1. `ANIMATION_START` * 2. `ANIMATION_UPDATE` (repeated for however many frames the animation has) * 3. `ANIMATION_REPEAT` (only if the animation is set to repeat, it then emits more update events after this) * 4. `ANIMATION_COMPLETE` (only if there is a finite, or zero, repeat count) * 5. `ANIMATION_COMPLETE_KEY` (only if there is a finite, or zero, repeat count) * * If the animation is stopped directly, the `ANIMATION_STOP` event is dispatched instead of `ANIMATION_COMPLETE`. * * If the animation is restarted while it is already playing, `ANIMATION_RESTART` is emitted. * * @event Phaser.Animations.Events#ANIMATION_UPDATE * @type {string} * @since 3.50.0 * * @param {Phaser.Animations.Animation} animation - A reference to the Animation that has updated. * @param {Phaser.Animations.AnimationFrame} frame - The current Animation Frame of the Animation. * @param {Phaser.GameObjects.Sprite} gameObject - A reference to the Game Object on which the animation updated. * @param {string} frameKey - The unique key of the Animation Frame within the Animation. */ module.exports = 'animationupdate'; /***/ }), /***/ 52562: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Pause All Animations Event. * * This event is dispatched when the global Animation Manager is told to pause. * * When this happens all current animations will stop updating, although it doesn't necessarily mean * that the game has paused as well. * * @event Phaser.Animations.Events#PAUSE_ALL * @type {string} * @since 3.0.0 */ module.exports = 'pauseall'; /***/ }), /***/ 57953: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Remove Animation Event. * * This event is dispatched when an animation is removed from the global Animation Manager. * * @event Phaser.Animations.Events#REMOVE_ANIMATION * @type {string} * @since 3.0.0 * * @param {string} key - The key of the Animation that was removed from the global Animation Manager. * @param {Phaser.Animations.Animation} animation - An instance of the removed Animation. */ module.exports = 'remove'; /***/ }), /***/ 68339: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Resume All Animations Event. * * This event is dispatched when the global Animation Manager resumes, having been previously paused. * * When this happens all current animations will continue updating again. * * @event Phaser.Animations.Events#RESUME_ALL * @type {string} * @since 3.0.0 */ module.exports = 'resumeall'; /***/ }), /***/ 74943: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Animations.Events */ module.exports = { ADD_ANIMATION: __webpack_require__(57090), ANIMATION_COMPLETE: __webpack_require__(25312), ANIMATION_COMPLETE_KEY: __webpack_require__(89580), ANIMATION_REPEAT: __webpack_require__(52860), ANIMATION_RESTART: __webpack_require__(63850), ANIMATION_START: __webpack_require__(99085), ANIMATION_STOP: __webpack_require__(28087), ANIMATION_UPDATE: __webpack_require__(1794), PAUSE_ALL: __webpack_require__(52562), REMOVE_ANIMATION: __webpack_require__(57953), RESUME_ALL: __webpack_require__(68339) }; /***/ }), /***/ 60421: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Animations */ module.exports = { Animation: __webpack_require__(42099), AnimationFrame: __webpack_require__(41138), AnimationManager: __webpack_require__(60848), AnimationState: __webpack_require__(9674), Events: __webpack_require__(74943) }; /***/ }), /***/ 2161: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Class = __webpack_require__(83419); var CustomMap = __webpack_require__(90330); var EventEmitter = __webpack_require__(50792); var Events = __webpack_require__(24736); /** * @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 {Phaser.Events.EventEmitter} * @since 3.0.0 */ this.events = new EventEmitter(); }, /** * 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.Events#ADD * @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 {this} This BaseCache object. */ add: function (key, data) { this.entries.set(key, data); this.events.emit(Events.ADD, this, key, data); return this; }, /** * Checks if this cache contains an item matching the given key. * This performs the same action as `BaseCache.exists`. * * @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); }, /** * Checks if this cache contains an item matching the given key. * This performs the same action as `BaseCache.has` and is called directly by the Loader. * * @method Phaser.Cache.BaseCache#exists * @since 3.7.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`. */ exists: 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); }, /** * 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.Events#REMOVE * @since 3.0.0 * * @param {string} key - The unique key of the item to remove from the cache. * * @return {this} This BaseCache object. */ remove: function (key) { var entry = this.get(key); if (entry) { this.entries.delete(key); this.events.emit(Events.REMOVE, this, key, entry.data); } return this; }, /** * Returns all keys in use in this cache. * * @method Phaser.Cache.BaseCache#getKeys * @since 3.17.0 * * @return {string[]} Array containing all the keys. */ getKeys: function () { return this.entries.keys(); }, /** * 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; /***/ }), /***/ 24047: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var BaseCache = __webpack_require__(2161); var Class = __webpack_require__(83419); var GameEvents = __webpack_require__(8443); /** * @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} * @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} * @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} * @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} * @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} * @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} * @since 3.0.0 */ this.audio = new BaseCache(); /** * A Cache storing all non-streaming video files, typically added via the Loader. * * @name Phaser.Cache.CacheManager#video * @type {Phaser.Cache.BaseCache} * @since 3.20.0 */ this.video = new BaseCache(); /** * A Cache storing all text files, typically added via the Loader. * * @name Phaser.Cache.CacheManager#text * @type {Phaser.Cache.BaseCache} * @since 3.0.0 */ this.text = new BaseCache(); /** * A Cache storing all html files, typically added via the Loader. * * @name Phaser.Cache.CacheManager#html * @type {Phaser.Cache.BaseCache} * @since 3.12.0 */ this.html = new BaseCache(); /** * A Cache storing all WaveFront OBJ files, typically added via the Loader. * * @name Phaser.Cache.CacheManager#obj * @type {Phaser.Cache.BaseCache} * @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} * @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} * @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.} * @since 3.0.0 */ this.custom = {}; this.game.events.once(GameEvents.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', 'video', 'text', 'html', '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; /***/ }), /***/ 51464: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Cache Add Event. * * This event is dispatched by any Cache that extends the BaseCache each time a new object is added to it. * * @event Phaser.Cache.Events#ADD * @type {string} * @since 3.0.0 * * @param {Phaser.Cache.BaseCache} cache - The cache to which the object was added. * @param {string} key - The key of the object added to the cache. * @param {*} object - A reference to the object that was added to the cache. */ module.exports = 'add'; /***/ }), /***/ 59261: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Cache Remove Event. * * This event is dispatched by any Cache that extends the BaseCache each time an object is removed from it. * * @event Phaser.Cache.Events#REMOVE * @type {string} * @since 3.0.0 * * @param {Phaser.Cache.BaseCache} cache - The cache from which the object was removed. * @param {string} key - The key of the object removed from the cache. * @param {*} object - A reference to the object that was removed from the cache. */ module.exports = 'remove'; /***/ }), /***/ 24736: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Cache.Events */ module.exports = { ADD: __webpack_require__(51464), REMOVE: __webpack_require__(59261) }; /***/ }), /***/ 83388: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Cache */ module.exports = { BaseCache: __webpack_require__(2161), CacheManager: __webpack_require__(24047), Events: __webpack_require__(24736) }; /***/ }), /***/ 71911: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Class = __webpack_require__(83419); var Components = __webpack_require__(31401); var DegToRad = __webpack_require__(39506); var EventEmitter = __webpack_require__(50792); var Events = __webpack_require__(19715); var Rectangle = __webpack_require__(87841); var TransformMatrix = __webpack_require__(61340); var ValueToColor = __webpack_require__(80333); var Vector2 = __webpack_require__(26099); /** * @classdesc * A Base Camera class. * * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, * and can be positioned, rotated, zoomed and scrolled accordingly. * * A Camera consists of two elements: The viewport and the scroll values. * * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are * created the same size as your game, but their position and size can be set to anything. This means if you * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). * * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the * viewport, and changing the viewport has no impact on the scrolling. * * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, * allowing you to filter Game Objects out on a per-Camera basis. * * The Base Camera is extended by the Camera class, which adds in special effects including Fade, * Flash and Camera Shake, as well as the ability to follow Game Objects. * * The Base Camera was introduced in Phaser 3.12. It was split off from the Camera class, to allow * you to isolate special effects as needed. Therefore the 'since' values for properties of this class relate * to when they were added to the Camera class. * * @class BaseCamera * @memberof Phaser.Cameras.Scene2D * @constructor * @since 3.12.0 * * @extends Phaser.Events.EventEmitter * @extends Phaser.GameObjects.Components.Alpha * @extends Phaser.GameObjects.Components.Visible * * @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 BaseCamera = new Class({ Extends: EventEmitter, Mixins: [ Components.AlphaSingle, Components.Visible ], initialize: function BaseCamera (x, y, width, height) { if (x === undefined) { x = 0; } if (y === undefined) { y = 0; } if (width === undefined) { width = 0; } if (height === undefined) { height = 0; } EventEmitter.call(this); /** * A reference to the Scene this camera belongs to. * * @name Phaser.Cameras.Scene2D.BaseCamera#scene * @type {Phaser.Scene} * @since 3.0.0 */ this.scene; /** * A reference to the Game Scene Manager. * * @name Phaser.Cameras.Scene2D.BaseCamera#sceneManager * @type {Phaser.Scenes.SceneManager} * @since 3.12.0 */ this.sceneManager; /** * A reference to the Game Scale Manager. * * @name Phaser.Cameras.Scene2D.BaseCamera#scaleManager * @type {Phaser.Scale.ScaleManager} * @since 3.16.0 */ this.scaleManager; /** * A reference to the Scene's Camera Manager to which this Camera belongs. * * @name Phaser.Cameras.Scene2D.BaseCamera#cameraManager * @type {Phaser.Cameras.Scene2D.CameraManager} * @since 3.17.0 */ this.cameraManager; /** * The Camera ID. Assigned by the Camera Manager and used to handle camera exclusion. * This value is a bitmask. * * @name Phaser.Cameras.Scene2D.BaseCamera#id * @type {number} * @readonly * @since 3.11.0 */ this.id = 0; /** * The name of the Camera. This is left empty for your own use. * * @name Phaser.Cameras.Scene2D.BaseCamera#name * @type {string} * @default '' * @since 3.0.0 */ this.name = ''; /** * Should this camera round its pixel values to integers? * * @name Phaser.Cameras.Scene2D.BaseCamera#roundPixels * @type {boolean} * @default false * @since 3.0.0 */ this.roundPixels = false; /** * Is this Camera visible or not? * * A visible camera will render and perform input tests. * An invisible camera will not render anything and will skip input tests. * * @name Phaser.Cameras.Scene2D.BaseCamera#visible * @type {boolean} * @default true * @since 3.10.0 */ /** * Is this Camera using a bounds to restrict scrolling movement? * * Set this property along with the bounds via `Camera.setBounds`. * * @name Phaser.Cameras.Scene2D.BaseCamera#useBounds * @type {boolean} * @default false * @since 3.0.0 */ this.useBounds = false; /** * The World View is a Rectangle that defines the area of the 'world' the Camera is currently looking at. * This factors in the Camera viewport size, zoom and scroll position and is updated in the Camera preRender step. * If you have enabled Camera bounds the worldview will be clamped to those bounds accordingly. * You can use it for culling or intersection checks. * * @name Phaser.Cameras.Scene2D.BaseCamera#worldView * @type {Phaser.Geom.Rectangle} * @readonly * @since 3.11.0 */ this.worldView = new Rectangle(); /** * Is this Camera dirty? * * A dirty Camera has had either its viewport size, bounds, scroll, rotation or zoom levels changed since the last frame. * * This flag is cleared during the `postRenderCamera` method of the renderer. * * @name Phaser.Cameras.Scene2D.BaseCamera#dirty * @type {boolean} * @default true * @since 3.11.0 */ this.dirty = true; /** * The x position of the Camera viewport, relative to the top-left of the game canvas. * The viewport is the area into which the camera renders. * To adjust the position the camera is looking at in the game world, see the `scrollX` value. * * @name Phaser.Cameras.Scene2D.BaseCamera#_x * @type {number} * @private * @since 3.0.0 */ this._x = x; /** * The y position of the Camera, relative to the top-left of the game canvas. * The viewport is the area into which the camera renders. * To adjust the position the camera is looking at in the game world, see the `scrollY` value. * * @name Phaser.Cameras.Scene2D.BaseCamera#_y * @type {number} * @private * @since 3.0.0 */ this._y = y; /** * The width of the Camera viewport, in pixels. * * The viewport is the area into which the Camera renders. Setting the viewport does * not restrict where the Camera can scroll to. * * @name Phaser.Cameras.Scene2D.BaseCamera#_width * @type {number} * @private * @since 3.11.0 */ this._width = width; /** * The height of the Camera viewport, in pixels. * * The viewport is the area into which the Camera renders. Setting the viewport does * not restrict where the Camera can scroll to. * * @name Phaser.Cameras.Scene2D.BaseCamera#_height * @type {number} * @private * @since 3.11.0 */ this._height = height; /** * The bounds the camera is restrained to during scrolling. * * @name Phaser.Cameras.Scene2D.BaseCamera#_bounds * @type {Phaser.Geom.Rectangle} * @private * @since 3.0.0 */ this._bounds = new Rectangle(); /** * The horizontal scroll position of this Camera. * * Change this value to cause the Camera to scroll around your Scene. * * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, * will automatically adjust the Camera scroll values accordingly. * * You can set the bounds within which the Camera can scroll via the `setBounds` method. * * @name Phaser.Cameras.Scene2D.BaseCamera#_scrollX * @type {number} * @private * @default 0 * @since 3.11.0 */ this._scrollX = 0; /** * The vertical scroll position of this Camera. * * Change this value to cause the Camera to scroll around your Scene. * * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, * will automatically adjust the Camera scroll values accordingly. * * You can set the bounds within which the Camera can scroll via the `setBounds` method. * * @name Phaser.Cameras.Scene2D.BaseCamera#_scrollY * @type {number} * @private * @default 0 * @since 3.11.0 */ this._scrollY = 0; /** * The Camera horizontal zoom value. Change this value to zoom in, or out of, a Scene. * * A value of 0.5 would zoom the Camera out, so you can now see twice as much * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel * now takes up 2 pixels when rendered. * * Set to 1 to return to the default zoom level. * * Be careful to never set this value to zero. * * @name Phaser.Cameras.Scene2D.BaseCamera#_zoomX * @type {number} * @private * @default 1 * @since 3.50.0 */ this._zoomX = 1; /** * The Camera vertical zoom value. Change this value to zoom in, or out of, a Scene. * * A value of 0.5 would zoom the Camera out, so you can now see twice as much * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel * now takes up 2 pixels when rendered. * * Set to 1 to return to the default zoom level. * * Be careful to never set this value to zero. * * @name Phaser.Cameras.Scene2D.BaseCamera#_zoomY * @type {number} * @private * @default 1 * @since 3.50.0 */ this._zoomY = 1; /** * The rotation of the Camera in radians. * * Camera rotation always takes place based on the Camera viewport. By default, rotation happens * in the center of the viewport. You can adjust this with the `originX` and `originY` properties. * * Rotation influences the rendering of _all_ Game Objects visible by this Camera. However, it does not * rotate the Camera viewport itself, which always remains an axis-aligned rectangle. * * @name Phaser.Cameras.Scene2D.BaseCamera#_rotation * @type {number} * @private * @default 0 * @since 3.11.0 */ this._rotation = 0; /** * A local transform matrix used for internal calculations. * * @name Phaser.Cameras.Scene2D.BaseCamera#matrix * @type {Phaser.GameObjects.Components.TransformMatrix} * @private * @since 3.0.0 */ this.matrix = new TransformMatrix(); /** * Does this Camera have a transparent background? * * @name Phaser.Cameras.Scene2D.BaseCamera#transparent * @type {boolean} * @default true * @since 3.0.0 */ this.transparent = true; /** * The background color of this Camera. Only used if `transparent` is `false`. * * @name Phaser.Cameras.Scene2D.BaseCamera#backgroundColor * @type {Phaser.Display.Color} * @since 3.0.0 */ this.backgroundColor = ValueToColor('rgba(0,0,0,0)'); /** * The Camera alpha value. Setting this property impacts every single object that this Camera * renders. You can either set the property directly, i.e. via a Tween, to fade a Camera in or out, * or via the chainable `setAlpha` method instead. * * @name Phaser.Cameras.Scene2D.BaseCamera#alpha * @type {number} * @default 1 * @since 3.11.0 */ /** * Should the camera cull Game Objects before checking them for input hit tests? * In some special cases it may be beneficial to disable this. * * @name Phaser.Cameras.Scene2D.BaseCamera#disableCull * @type {boolean} * @default false * @since 3.0.0 */ this.disableCull = false; /** * A temporary array of culled objects. * * @name Phaser.Cameras.Scene2D.BaseCamera#culledObjects * @type {Phaser.GameObjects.GameObject[]} * @default [] * @private * @since 3.0.0 */ this.culledObjects = []; /** * The mid-point of the Camera in 'world' coordinates. * * Use it to obtain exactly where in the world the center of the camera is currently looking. * * This value is updated in the preRender method, after the scroll values and follower * have been processed. * * @name Phaser.Cameras.Scene2D.BaseCamera#midPoint * @type {Phaser.Math.Vector2} * @readonly * @since 3.11.0 */ this.midPoint = new Vector2(width / 2, height / 2); /** * The horizontal origin of rotation for this Camera. * * By default the camera rotates around the center of the viewport. * * Changing the origin allows you to adjust the point in the viewport from which rotation happens. * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. * * See `setOrigin` to set both origins in a single, chainable call. * * @name Phaser.Cameras.Scene2D.BaseCamera#originX * @type {number} * @default 0.5 * @since 3.11.0 */ this.originX = 0.5; /** * The vertical origin of rotation for this Camera. * * By default the camera rotates around the center of the viewport. * * Changing the origin allows you to adjust the point in the viewport from which rotation happens. * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. * * See `setOrigin` to set both origins in a single, chainable call. * * @name Phaser.Cameras.Scene2D.BaseCamera#originY * @type {number} * @default 0.5 * @since 3.11.0 */ this.originY = 0.5; /** * Does this Camera have a custom viewport? * * @name Phaser.Cameras.Scene2D.BaseCamera#_customViewport * @type {boolean} * @private * @default false * @since 3.12.0 */ this._customViewport = false; /** * The Mask this Camera is using during render. * Set the mask using the `setMask` method. Remove the mask using the `clearMask` method. * * @name Phaser.Cameras.Scene2D.BaseCamera#mask * @type {?(Phaser.Display.Masks.BitmapMask|Phaser.Display.Masks.GeometryMask)} * @since 3.17.0 */ this.mask = null; /** * The Camera that this Camera uses for translation during masking. * * If the mask is fixed in position this will be a reference to * the CameraManager.default instance. Otherwise, it'll be a reference * to itself. * * @name Phaser.Cameras.Scene2D.BaseCamera#_maskCamera * @type {?Phaser.Cameras.Scene2D.BaseCamera} * @private * @since 3.17.0 */ this._maskCamera = null; /** * This array is populated with all of the Game Objects that this Camera has rendered * in the previous (or current, depending on when you inspect it) frame. * * It is cleared at the start of `Camera.preUpdate`, or if the Camera is destroyed. * * You should not modify this array as it is used internally by the input system, * however you can read it as required. Note that Game Objects may appear in this * list multiple times if they belong to multiple non-exclusive Containers. * * @name Phaser.Cameras.Scene2D.BaseCamera#renderList * @type {Phaser.GameObjects.GameObject[]} * @since 3.52.0 */ this.renderList = []; /** * Is this Camera a Scene Camera? (which is the default), or a Camera * belonging to a Texture? * * @name Phaser.Cameras.Scene2D.BaseCamera#isSceneCamera * @type {boolean} * @default true * @since 3.60.0 */ this.isSceneCamera = true; /** * Can this Camera render rounded pixel values? * * This property is updated during the `preRender` method and should not be * set directly. It is set based on the `roundPixels` property of the Camera * combined with the zoom level. If the zoom is an integer then the WebGL * Renderer can apply rounding during rendering. * * @name Phaser.Cameras.Scene2D.BaseCamera#renderRoundPixels * @type {boolean} * @readonly * @default true * @since 3.86.0 */ this.renderRoundPixels = true; }, /** * Adds the given Game Object to this cameras render list. * * This is invoked during the rendering stage. Only objects that are actually rendered * will appear in the render list. * * @method Phaser.Cameras.Scene2D.BaseCamera#addToRenderList * @since 3.52.0 * * @param {Phaser.GameObjects.GameObject} child - The Game Object to add to the render list. */ addToRenderList: function (child) { this.renderList.push(child); }, /** * Set the Alpha level of this Camera. The alpha controls the opacity of the Camera as it renders. * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. * * @method Phaser.Cameras.Scene2D.BaseCamera#setAlpha * @since 3.11.0 * * @param {number} [value=1] - The Camera alpha value. * * @return {this} This Camera instance. */ /** * Sets the rotation origin of this Camera. * * The values are given in the range 0 to 1 and are only used when calculating Camera rotation. * * By default the camera rotates around the center of the viewport. * * Changing the origin allows you to adjust the point in the viewport from which rotation happens. * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. * * @method Phaser.Cameras.Scene2D.BaseCamera#setOrigin * @since 3.11.0 * * @param {number} [x=0.5] - The horizontal origin value. * @param {number} [y=x] - The vertical origin value. If not defined it will be set to the value of `x`. * * @return {this} This Camera instance. */ setOrigin: function (x, y) { if (x === undefined) { x = 0.5; } if (y === undefined) { y = x; } this.originX = x; this.originY = y; return this; }, /** * Calculates what the Camera.scrollX and scrollY values would need to be in order to move * the Camera so it is centered on the given x and y coordinates, without actually moving * the Camera there. The results are clamped based on the Camera bounds, if set. * * @method Phaser.Cameras.Scene2D.BaseCamera#getScroll * @since 3.11.0 * * @param {number} x - The horizontal coordinate to center on. * @param {number} y - The vertical coordinate to center on. * @param {Phaser.Math.Vector2} [out] - A Vector2 to store the values in. If not given a new Vector2 is created. * * @return {Phaser.Math.Vector2} The scroll coordinates stored in the `x` and `y` properties. */ getScroll: function (x, y, out) { if (out === undefined) { out = new Vector2(); } var originX = this.width * 0.5; var originY = this.height * 0.5; out.x = x - originX; out.y = y - originY; if (this.useBounds) { out.x = this.clampX(out.x); out.y = this.clampY(out.y); } return out; }, /** * Moves the Camera horizontally so that it is centered on the given x coordinate, bounds allowing. * Calling this does not change the scrollY value. * * @method Phaser.Cameras.Scene2D.BaseCamera#centerOnX * @since 3.16.0 * * @param {number} x - The horizontal coordinate to center on. * * @return {this} This Camera instance. */ centerOnX: function (x) { var originX = this.width * 0.5; this.midPoint.x = x; this.scrollX = x - originX; if (this.useBounds) { this.scrollX = this.clampX(this.scrollX); } return this; }, /** * Moves the Camera vertically so that it is centered on the given y coordinate, bounds allowing. * Calling this does not change the scrollX value. * * @method Phaser.Cameras.Scene2D.BaseCamera#centerOnY * @since 3.16.0 * * @param {number} y - The vertical coordinate to center on. * * @return {this} This Camera instance. */ centerOnY: function (y) { var originY = this.height * 0.5; this.midPoint.y = y; this.scrollY = y - originY; if (this.useBounds) { this.scrollY = this.clampY(this.scrollY); } return this; }, /** * Moves the Camera so that it is centered on the given coordinates, bounds allowing. * * @method Phaser.Cameras.Scene2D.BaseCamera#centerOn * @since 3.11.0 * * @param {number} x - The horizontal coordinate to center on. * @param {number} y - The vertical coordinate to center on. * * @return {this} This Camera instance. */ centerOn: function (x, y) { this.centerOnX(x); this.centerOnY(y); return this; }, /** * Moves the Camera so that it is looking at the center of the Camera Bounds, if enabled. * * @method Phaser.Cameras.Scene2D.BaseCamera#centerToBounds * @since 3.0.0 * * @return {this} This Camera instance. */ centerToBounds: function () { if (this.useBounds) { var bounds = this._bounds; var originX = this.width * 0.5; var originY = this.height * 0.5; this.midPoint.set(bounds.centerX, bounds.centerY); this.scrollX = bounds.centerX - originX; this.scrollY = bounds.centerY - originY; } return this; }, /** * Moves the Camera so that it is re-centered based on its viewport size. * * @method Phaser.Cameras.Scene2D.BaseCamera#centerToSize * @since 3.0.0 * * @return {this} This Camera instance. */ centerToSize: function () { this.scrollX = this.width * 0.5; this.scrollY = this.height * 0.5; return this; }, /** * Takes an array of Game Objects and returns a new array featuring only those objects * visible by this camera. * * @method Phaser.Cameras.Scene2D.BaseCamera#cull * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject[]} G - [renderableObjects,$return] * * @param {Phaser.GameObjects.GameObject[]} renderableObjects - An array of Game Objects to cull. * * @return {Phaser.GameObjects.GameObject[]} An array of Game Objects visible to this Camera. */ cull: function (renderableObjects) { if (this.disableCull) { 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 cullTop = this.y; var cullBottom = cullTop + cameraH; var cullLeft = this.x; var cullRight = cullLeft + cameraW; 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') || object.parentContainer) { 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); if ((tw > cullLeft && tx < cullRight) && (th > cullTop && ty < cullBottom)) { culledObjects.push(object); } } return culledObjects; }, /** * Converts the given `x` and `y` coordinates into World space, based on this Cameras transform. * You can optionally provide a Vector2, or similar object, to store the results in. * * @method Phaser.Cameras.Scene2D.BaseCamera#getWorldPoint * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [output,$return] * * @param {number} x - The x position to convert to world space. * @param {number} y - The y position to convert to world space. * @param {(object|Phaser.Math.Vector2)} [output] - An optional object to store the results in. If not provided a new Vector2 will be created. * * @return {Phaser.Math.Vector2} An object holding the converted values in its `x` and `y` properties. */ 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]; // 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 zoomX = this.zoomX; var zoomY = this.zoomY; var scrollX = this.scrollX; var scrollY = this.scrollY; var sx = x + ((scrollX * c - scrollY * s) * zoomX); var sy = y + ((scrollX * s + scrollY * c) * zoomY); // Apply transform to point output.x = (sx * ima + sy * imc) + ime; output.y = (sx * imb + sy * imd) + imf; return output; }, /** * Given a Game Object, or an array of Game Objects, it will update all of their camera filter settings * so that they are ignored by this Camera. This means they will not be rendered by this Camera. * * @method Phaser.Cameras.Scene2D.BaseCamera#ignore * @since 3.0.0 * * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Layer|Phaser.GameObjects.Layer[])} entries - The Game Object, or array of Game Objects, to be ignored by this Camera. * * @return {this} This Camera instance. */ ignore: function (entries) { var id = this.id; if (!Array.isArray(entries)) { entries = [ entries ]; } for (var i = 0; i < entries.length; i++) { var entry = entries[i]; if (Array.isArray(entry)) { this.ignore(entry); } else if (entry.isParent) { this.ignore(entry.getChildren()); } else { entry.cameraFilter |= id; } } return this; }, /** * Takes an x value and checks it's within the range of the Camera bounds, adjusting if required. * Do not call this method if you are not using camera bounds. * * @method Phaser.Cameras.Scene2D.BaseCamera#clampX * @since 3.11.0 * * @param {number} x - The value to horizontally scroll clamp. * * @return {number} The adjusted value to use as scrollX. */ clampX: function (x) { var bounds = this._bounds; var dw = this.displayWidth; var bx = bounds.x + ((dw - this.width) / 2); var bw = Math.max(bx, bx + bounds.width - dw); if (x < bx) { x = bx; } else if (x > bw) { x = bw; } return x; }, /** * Takes a y value and checks it's within the range of the Camera bounds, adjusting if required. * Do not call this method if you are not using camera bounds. * * @method Phaser.Cameras.Scene2D.BaseCamera#clampY * @since 3.11.0 * * @param {number} y - The value to vertically scroll clamp. * * @return {number} The adjusted value to use as scrollY. */ clampY: function (y) { var bounds = this._bounds; var dh = this.displayHeight; var by = bounds.y + ((dh - this.height) / 2); var bh = Math.max(by, by + bounds.height - dh); if (y < by) { y = by; } else if (y > bh) { y = bh; } return y; }, /* var gap = this._zoomInversed; return gap * Math.round((src.x - this.scrollX * src.scrollFactorX) / gap); */ /** * If this Camera has previously had movement bounds set on it, this will remove them. * * @method Phaser.Cameras.Scene2D.BaseCamera#removeBounds * @since 3.0.0 * * @return {this} This Camera instance. */ removeBounds: function () { this.useBounds = false; this.dirty = true; this._bounds.setEmpty(); return this; }, /** * Set the rotation of this Camera. This causes everything it renders to appear rotated. * * Rotating a camera does not rotate the viewport itself, it is applied during rendering. * * @method Phaser.Cameras.Scene2D.BaseCamera#setAngle * @since 3.0.0 * * @param {number} [value=0] - The cameras angle of rotation, given in degrees. * * @return {this} This Camera instance. */ setAngle: function (value) { if (value === undefined) { value = 0; } this.rotation = DegToRad(value); return this; }, /** * Sets the background color for this Camera. * * By default a Camera has a transparent background but it can be given a solid color, with any level * of transparency, via this method. * * The color value can be specified using CSS color notation, hex or numbers. * * @method Phaser.Cameras.Scene2D.BaseCamera#setBackgroundColor * @since 3.0.0 * * @param {(string|number|Phaser.Types.Display.InputColorObject)} [color='rgba(0,0,0,0)'] - The color value. In CSS, hex or numeric color notation. * * @return {this} 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; }, /** * Set the bounds of the Camera. The bounds are an axis-aligned rectangle. * * The Camera bounds controls where the Camera can scroll to, stopping it from scrolling off the * edges and into blank space. It does not limit the placement of Game Objects, or where * the Camera viewport can be positioned. * * Temporarily disable the bounds by changing the boolean `Camera.useBounds`. * * Clear the bounds entirely by calling `Camera.removeBounds`. * * If you set bounds that are smaller than the viewport it will stop the Camera from being * able to scroll. The bounds can be positioned where-ever you wish. By default they are from * 0x0 to the canvas width x height. This means that the coordinate 0x0 is the top left of * the Camera bounds. However, you can position them anywhere. So if you wanted a game world * that was 2048x2048 in size, with 0x0 being the center of it, you can set the bounds x/y * to be -1024, -1024, with a width and height of 2048. Depending on your game you may find * it easier for 0x0 to be the top-left of the bounds, or you may wish 0x0 to be the middle. * * @method Phaser.Cameras.Scene2D.BaseCamera#setBounds * @since 3.0.0 * * @param {number} x - The top-left x coordinate of the bounds. * @param {number} y - The top-left y coordinate of the bounds. * @param {number} width - The width of the bounds, in pixels. * @param {number} height - The height of the bounds, in pixels. * @param {boolean} [centerOn=false] - If `true` the Camera will automatically be centered on the new bounds. * * @return {this} This Camera instance. */ setBounds: function (x, y, width, height, centerOn) { if (centerOn === undefined) { centerOn = false; } this._bounds.setTo(x, y, width, height); this.dirty = true; this.useBounds = true; if (centerOn) { this.centerToBounds(); } else { this.scrollX = this.clampX(this.scrollX); this.scrollY = this.clampY(this.scrollY); } return this; }, /** * Returns a rectangle containing the bounds of the Camera. * * If the Camera does not have any bounds the rectangle will be empty. * * The rectangle is a copy of the bounds, so is safe to modify. * * @method Phaser.Cameras.Scene2D.BaseCamera#getBounds * @since 3.16.0 * * @param {Phaser.Geom.Rectangle} [out] - An optional Rectangle to store the bounds in. If not given, a new Rectangle will be created. * * @return {Phaser.Geom.Rectangle} A rectangle containing the bounds of this Camera. */ getBounds: function (out) { if (out === undefined) { out = new Rectangle(); } var source = this._bounds; out.setTo(source.x, source.y, source.width, source.height); return out; }, /** * Sets the name of this Camera. * This value is for your own use and isn't used internally. * * @method Phaser.Cameras.Scene2D.BaseCamera#setName * @since 3.0.0 * * @param {string} [value=''] - The name of the Camera. * * @return {this} This Camera instance. */ setName: function (value) { if (value === undefined) { value = ''; } this.name = value; return this; }, /** * Set the position of the Camera viewport within the game. * * This does not change where the camera is 'looking'. See `setScroll` to control that. * * @method Phaser.Cameras.Scene2D.BaseCamera#setPosition * @since 3.0.0 * * @param {number} x - The top-left x coordinate of the Camera viewport. * @param {number} [y=x] - The top-left y coordinate of the Camera viewport. * * @return {this} This Camera instance. */ setPosition: function (x, y) { if (y === undefined) { y = x; } this.x = x; this.y = y; return this; }, /** * Set the rotation of this Camera. This causes everything it renders to appear rotated. * * Rotating a camera does not rotate the viewport itself, it is applied during rendering. * * @method Phaser.Cameras.Scene2D.BaseCamera#setRotation * @since 3.0.0 * * @param {number} [value=0] - The rotation of the Camera, in radians. * * @return {this} This Camera instance. */ setRotation: function (value) { if (value === undefined) { value = 0; } this.rotation = value; return this; }, /** * Should the Camera round pixel values to whole integers when rendering Game Objects? * * In some types of game, especially with pixel art, this is required to prevent sub-pixel aliasing. * * @method Phaser.Cameras.Scene2D.BaseCamera#setRoundPixels * @since 3.0.0 * * @param {boolean} value - `true` to round Camera pixels, `false` to not. * * @return {this} This Camera instance. */ setRoundPixels: function (value) { this.roundPixels = value; return this; }, /** * Sets the Scene the Camera is bound to. * * @method Phaser.Cameras.Scene2D.BaseCamera#setScene * @since 3.0.0 * * @param {Phaser.Scene} scene - The Scene the camera is bound to. * @param {boolean} [isSceneCamera=true] - Is this Camera being used for a Scene (true) or a Texture? (false) * * @return {this} This Camera instance. */ setScene: function (scene, isSceneCamera) { if (isSceneCamera === undefined) { isSceneCamera = true; } if (this.scene && this._customViewport) { this.sceneManager.customViewports--; } this.scene = scene; this.isSceneCamera = isSceneCamera; var sys = scene.sys; this.sceneManager = sys.game.scene; this.scaleManager = sys.scale; this.cameraManager = sys.cameras; this.updateSystem(); return this; }, /** * Set the position of where the Camera is looking within the game. * You can also modify the properties `Camera.scrollX` and `Camera.scrollY` directly. * Use this method, or the scroll properties, to move your camera around the game world. * * This does not change where the camera viewport is placed. See `setPosition` to control that. * * @method Phaser.Cameras.Scene2D.BaseCamera#setScroll * @since 3.0.0 * * @param {number} x - The x coordinate of the Camera in the game world. * @param {number} [y=x] - The y coordinate of the Camera in the game world. * * @return {this} This Camera instance. */ setScroll: function (x, y) { if (y === undefined) { y = x; } this.scrollX = x; this.scrollY = y; return this; }, /** * Set the size of the Camera viewport. * * By default a Camera is the same size as the game, but can be made smaller via this method, * allowing you to create mini-cam style effects by creating and positioning a smaller Camera * viewport within your game. * * @method Phaser.Cameras.Scene2D.BaseCamera#setSize * @since 3.0.0 * * @param {number} width - The width of the Camera viewport. * @param {number} [height=width] - The height of the Camera viewport. * * @return {this} This Camera instance. */ setSize: function (width, height) { if (height === undefined) { height = width; } this.width = width; this.height = height; return this; }, /** * This method sets the position and size of the Camera viewport in a single call. * * If you're trying to change where the Camera is looking at in your game, then see * the method `Camera.setScroll` instead. This method is for changing the viewport * itself, not what the camera can see. * * By default a Camera is the same size as the game, but can be made smaller via this method, * allowing you to create mini-cam style effects by creating and positioning a smaller Camera * viewport within your game. * * @method Phaser.Cameras.Scene2D.BaseCamera#setViewport * @since 3.0.0 * * @param {number} x - The top-left x coordinate of the Camera viewport. * @param {number} y - The top-left y coordinate of the Camera viewport. * @param {number} width - The width of the Camera viewport. * @param {number} [height=width] - The height of the Camera viewport. * * @return {this} This Camera instance. */ setViewport: function (x, y, width, height) { this.x = x; this.y = y; this.width = width; this.height = height; return this; }, /** * Set the zoom value of the Camera. * * Changing to a smaller value, such as 0.5, will cause the camera to 'zoom out'. * Changing to a larger value, such as 2, will cause the camera to 'zoom in'. * * A value of 1 means 'no zoom' and is the default. * * Changing the zoom does not impact the Camera viewport in any way, it is only applied during rendering. * * As of Phaser 3.50 you can now set the horizontal and vertical zoom values independently. * * @method Phaser.Cameras.Scene2D.BaseCamera#setZoom * @since 3.0.0 * * @param {number} [x=1] - The horizontal zoom value of the Camera. The minimum it can be is 0.001. * @param {number} [y=x] - The vertical zoom value of the Camera. The minimum it can be is 0.001. * * @return {this} This Camera instance. */ setZoom: function (x, y) { if (x === undefined) { x = 1; } if (y === undefined) { y = x; } if (x === 0) { x = 0.001; } if (y === 0) { y = 0.001; } this.zoomX = x; this.zoomY = y; return this; }, /** * Sets the mask to be applied to this Camera during rendering. * * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * * Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Camera it will be immediately replaced. * * Masks have no impact on physics or input detection. They are purely a rendering component * that allows you to limit what is visible during the render pass. * * @method Phaser.Cameras.Scene2D.BaseCamera#setMask * @since 3.17.0 * * @param {(Phaser.Display.Masks.BitmapMask|Phaser.Display.Masks.GeometryMask)} mask - The mask this Camera will use when rendering. * @param {boolean} [fixedPosition=true] - Should the mask translate along with the Camera, or be fixed in place and not impacted by the Cameras transform? * * @return {this} This Camera instance. */ setMask: function (mask, fixedPosition) { if (fixedPosition === undefined) { fixedPosition = true; } this.mask = mask; this._maskCamera = (fixedPosition) ? this.cameraManager.default : this; return this; }, /** * Clears the mask that this Camera was using. * * @method Phaser.Cameras.Scene2D.BaseCamera#clearMask * @since 3.17.0 * * @param {boolean} [destroyMask=false] - Destroy the mask before clearing it? * * @return {this} This Camera instance. */ clearMask: function (destroyMask) { if (destroyMask === undefined) { destroyMask = false; } if (destroyMask && this.mask) { this.mask.destroy(); } this.mask = null; return this; }, /** * Sets the visibility of this Camera. * * An invisible Camera will skip rendering and input tests of everything it can see. * * @method Phaser.Cameras.Scene2D.BaseCamera#setVisible * @since 3.10.0 * * @param {boolean} value - The visible state of the Camera. * * @return {this} This Camera instance. */ /** * Returns an Object suitable for JSON storage containing all of the Camera viewport and rendering properties. * * @method Phaser.Cameras.Scene2D.BaseCamera#toJSON * @since 3.0.0 * * @return {Phaser.Types.Cameras.Scene2D.JSONCamera} A well-formed object suitable for conversion to JSON. */ 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; }, /** * Internal method called automatically by the Camera Manager. * * @method Phaser.Cameras.Scene2D.BaseCamera#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, in ms, elapsed since the last frame. */ update: function () { // NOOP }, /** * Set if this Camera is being used as a Scene Camera, or a Texture * Camera. * * @method Phaser.Cameras.Scene2D.BaseCamera#setIsSceneCamera * @since 3.60.0 * * @param {boolean} value - Is this being used as a Scene Camera, or a Texture camera? */ setIsSceneCamera: function (value) { this.isSceneCamera = value; return this; }, /** * Internal method called automatically when the viewport changes. * * @method Phaser.Cameras.Scene2D.BaseCamera#updateSystem * @private * @since 3.12.0 */ updateSystem: function () { if (!this.scaleManager || !this.isSceneCamera) { return; } var custom = (this._x !== 0 || this._y !== 0 || this.scaleManager.width !== this._width || this.scaleManager.height !== this._height); var sceneManager = this.sceneManager; if (custom && !this._customViewport) { // We need a custom viewport for this Camera sceneManager.customViewports++; } else if (!custom && this._customViewport) { // We're turning off a custom viewport for this Camera sceneManager.customViewports--; } this.dirty = true; this._customViewport = custom; }, /** * Destroys this Camera instance and its internal properties and references. * Once destroyed you cannot use this Camera again, even if re-added to a Camera Manager. * * This method is called automatically by `CameraManager.remove` if that methods `runDestroy` argument is `true`, which is the default. * * Unless you have a specific reason otherwise, always use `CameraManager.remove` and allow it to handle the camera destruction, * rather than calling this method directly. * * @method Phaser.Cameras.Scene2D.BaseCamera#destroy * @fires Phaser.Cameras.Scene2D.Events#DESTROY * @since 3.0.0 */ destroy: function () { this.emit(Events.DESTROY, this); this.removeAllListeners(); this.matrix.destroy(); this.culledObjects = []; if (this._customViewport) { // We're turning off a custom viewport for this Camera this.sceneManager.customViewports--; } this.renderList = []; this._bounds = null; this.scene = null; this.scaleManager = null; this.sceneManager = null; this.cameraManager = null; }, /** * The x position of the Camera viewport, relative to the top-left of the game canvas. * The viewport is the area into which the camera renders. * To adjust the position the camera is looking at in the game world, see the `scrollX` value. * * @name Phaser.Cameras.Scene2D.BaseCamera#x * @type {number} * @since 3.0.0 */ x: { get: function () { return this._x; }, set: function (value) { this._x = value; this.updateSystem(); } }, /** * The y position of the Camera viewport, relative to the top-left of the game canvas. * The viewport is the area into which the camera renders. * To adjust the position the camera is looking at in the game world, see the `scrollY` value. * * @name Phaser.Cameras.Scene2D.BaseCamera#y * @type {number} * @since 3.0.0 */ y: { get: function () { return this._y; }, set: function (value) { this._y = value; this.updateSystem(); } }, /** * The width of the Camera viewport, in pixels. * * The viewport is the area into which the Camera renders. Setting the viewport does * not restrict where the Camera can scroll to. * * @name Phaser.Cameras.Scene2D.BaseCamera#width * @type {number} * @since 3.0.0 */ width: { get: function () { return this._width; }, set: function (value) { this._width = value; this.updateSystem(); } }, /** * The height of the Camera viewport, in pixels. * * The viewport is the area into which the Camera renders. Setting the viewport does * not restrict where the Camera can scroll to. * * @name Phaser.Cameras.Scene2D.BaseCamera#height * @type {number} * @since 3.0.0 */ height: { get: function () { return this._height; }, set: function (value) { this._height = value; this.updateSystem(); } }, /** * The horizontal scroll position of this Camera. * * Change this value to cause the Camera to scroll around your Scene. * * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, * will automatically adjust the Camera scroll values accordingly. * * You can set the bounds within which the Camera can scroll via the `setBounds` method. * * @name Phaser.Cameras.Scene2D.BaseCamera#scrollX * @type {number} * @default 0 * @since 3.0.0 */ scrollX: { get: function () { return this._scrollX; }, set: function (value) { if (value !== this._scrollX) { this._scrollX = value; this.dirty = true; } } }, /** * The vertical scroll position of this Camera. * * Change this value to cause the Camera to scroll around your Scene. * * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, * will automatically adjust the Camera scroll values accordingly. * * You can set the bounds within which the Camera can scroll via the `setBounds` method. * * @name Phaser.Cameras.Scene2D.BaseCamera#scrollY * @type {number} * @default 0 * @since 3.0.0 */ scrollY: { get: function () { return this._scrollY; }, set: function (value) { if (value !== this._scrollY) { this._scrollY = value; this.dirty = true; } } }, /** * The Camera zoom value. Change this value to zoom in, or out of, a Scene. * * A value of 0.5 would zoom the Camera out, so you can now see twice as much * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel * now takes up 2 pixels when rendered. * * Set to 1 to return to the default zoom level. * * Be careful to never set this value to zero. * * @name Phaser.Cameras.Scene2D.BaseCamera#zoom * @type {number} * @default 1 * @since 3.0.0 */ zoom: { get: function () { return (this._zoomX + this._zoomY) / 2; }, set: function (value) { this._zoomX = value; this._zoomY = value; this.dirty = true; } }, /** * The Camera horizontal zoom value. Change this value to zoom in, or out of, a Scene. * * A value of 0.5 would zoom the Camera out, so you can now see twice as much * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel * now takes up 2 pixels when rendered. * * Set to 1 to return to the default zoom level. * * Be careful to never set this value to zero. * * @name Phaser.Cameras.Scene2D.BaseCamera#zoomX * @type {number} * @default 1 * @since 3.50.0 */ zoomX: { get: function () { return this._zoomX; }, set: function (value) { this._zoomX = value; this.dirty = true; } }, /** * The Camera vertical zoom value. Change this value to zoom in, or out of, a Scene. * * A value of 0.5 would zoom the Camera out, so you can now see twice as much * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel * now takes up 2 pixels when rendered. * * Set to 1 to return to the default zoom level. * * Be careful to never set this value to zero. * * @name Phaser.Cameras.Scene2D.BaseCamera#zoomY * @type {number} * @default 1 * @since 3.50.0 */ zoomY: { get: function () { return this._zoomY; }, set: function (value) { this._zoomY = value; this.dirty = true; } }, /** * The rotation of the Camera in radians. * * Camera rotation always takes place based on the Camera viewport. By default, rotation happens * in the center of the viewport. You can adjust this with the `originX` and `originY` properties. * * Rotation influences the rendering of _all_ Game Objects visible by this Camera. However, it does not * rotate the Camera viewport itself, which always remains an axis-aligned rectangle. * * @name Phaser.Cameras.Scene2D.BaseCamera#rotation * @type {number} * @private * @default 0 * @since 3.11.0 */ rotation: { get: function () { return this._rotation; }, set: function (value) { this._rotation = value; this.dirty = true; } }, /** * The horizontal position of the center of the Camera's viewport, relative to the left of the game canvas. * * @name Phaser.Cameras.Scene2D.BaseCamera#centerX * @type {number} * @readonly * @since 3.10.0 */ centerX: { get: function () { return this.x + (0.5 * this.width); } }, /** * The vertical position of the center of the Camera's viewport, relative to the top of the game canvas. * * @name Phaser.Cameras.Scene2D.BaseCamera#centerY * @type {number} * @readonly * @since 3.10.0 */ centerY: { get: function () { return this.y + (0.5 * this.height); } }, /** * The displayed width of the camera viewport, factoring in the camera zoom level. * * If a camera has a viewport width of 800 and a zoom of 0.5 then its display width * would be 1600, as it's displaying twice as many pixels as zoom level 1. * * Equally, a camera with a width of 800 and zoom of 2 would have a display width * of 400 pixels. * * @name Phaser.Cameras.Scene2D.BaseCamera#displayWidth * @type {number} * @readonly * @since 3.11.0 */ displayWidth: { get: function () { return this.width / this.zoomX; } }, /** * The displayed height of the camera viewport, factoring in the camera zoom level. * * If a camera has a viewport height of 600 and a zoom of 0.5 then its display height * would be 1200, as it's displaying twice as many pixels as zoom level 1. * * Equally, a camera with a height of 600 and zoom of 2 would have a display height * of 300 pixels. * * @name Phaser.Cameras.Scene2D.BaseCamera#displayHeight * @type {number} * @readonly * @since 3.11.0 */ displayHeight: { get: function () { return this.height / this.zoomY; } } }); module.exports = BaseCamera; /***/ }), /***/ 38058: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var BaseCamera = __webpack_require__(71911); var CenterOn = __webpack_require__(67502); var Clamp = __webpack_require__(45319); var Class = __webpack_require__(83419); var Components = __webpack_require__(31401); var Effects = __webpack_require__(20052); var Events = __webpack_require__(19715); var Linear = __webpack_require__(28915); var Rectangle = __webpack_require__(87841); var Vector2 = __webpack_require__(26099); /** * @classdesc * A Camera. * * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, * and can be positioned, rotated, zoomed and scrolled accordingly. * * A Camera consists of two elements: The viewport and the scroll values. * * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are * created the same size as your game, but their position and size can be set to anything. This means if you * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). * * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the * viewport, and changing the viewport has no impact on the scrolling. * * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, * allowing you to filter Game Objects out on a per-Camera basis. * * A Camera also has built-in special effects including Fade, Flash and Camera Shake. * * @class Camera * @memberof Phaser.Cameras.Scene2D * @constructor * @since 3.0.0 * * @extends Phaser.Cameras.Scene2D.BaseCamera * @extends Phaser.GameObjects.Components.PostPipeline * * @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({ Extends: BaseCamera, Mixins: [ Components.PostPipeline ], initialize: function Camera (x, y, width, height) { BaseCamera.call(this, x, y, width, height); this.initPostPipeline(); /** * 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 Camera Fade effect handler. * To fade this camera see the `Camera.fade` methods. * * @name Phaser.Cameras.Scene2D.Camera#fadeEffect * @type {Phaser.Cameras.Scene2D.Effects.Fade} * @since 3.5.0 */ this.fadeEffect = new Effects.Fade(this); /** * The Camera Flash effect handler. * To flash this camera see the `Camera.flash` method. * * @name Phaser.Cameras.Scene2D.Camera#flashEffect * @type {Phaser.Cameras.Scene2D.Effects.Flash} * @since 3.5.0 */ this.flashEffect = new Effects.Flash(this); /** * The Camera Shake effect handler. * To shake this camera see the `Camera.shake` method. * * @name Phaser.Cameras.Scene2D.Camera#shakeEffect * @type {Phaser.Cameras.Scene2D.Effects.Shake} * @since 3.5.0 */ this.shakeEffect = new Effects.Shake(this); /** * The Camera Pan effect handler. * To pan this camera see the `Camera.pan` method. * * @name Phaser.Cameras.Scene2D.Camera#panEffect * @type {Phaser.Cameras.Scene2D.Effects.Pan} * @since 3.11.0 */ this.panEffect = new Effects.Pan(this); /** * The Camera Rotate To effect handler. * To rotate this camera see the `Camera.rotateTo` method. * * @name Phaser.Cameras.Scene2D.Camera#rotateToEffect * @type {Phaser.Cameras.Scene2D.Effects.RotateTo} * @since 3.23.0 */ this.rotateToEffect = new Effects.RotateTo(this); /** * The Camera Zoom effect handler. * To zoom this camera see the `Camera.zoom` method. * * @name Phaser.Cameras.Scene2D.Camera#zoomEffect * @type {Phaser.Cameras.Scene2D.Effects.Zoom} * @since 3.11.0 */ this.zoomEffect = new Effects.Zoom(this); /** * The linear interpolation value to use when following a target. * * Can also be set via `setLerp` or as part of the `startFollow` call. * * The default values of 1 means the camera will instantly snap to the target coordinates. * A lower value, such as 0.1 means the camera will more slowly track the target, giving * a smooth transition. You can set the horizontal and vertical values independently, and also * adjust this value in real-time during your game. * * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. * * @name Phaser.Cameras.Scene2D.Camera#lerp * @type {Phaser.Math.Vector2} * @since 3.9.0 */ this.lerp = new Vector2(1, 1); /** * The values stored in this property are subtracted from the Camera targets position, allowing you to * offset the camera from the actual target x/y coordinates by this amount. * Can also be set via `setFollowOffset` or as part of the `startFollow` call. * * @name Phaser.Cameras.Scene2D.Camera#followOffset * @type {Phaser.Math.Vector2} * @since 3.9.0 */ this.followOffset = new Vector2(); /** * The Camera dead zone. * * The deadzone is only used when the camera is following a target. * * It defines a rectangular region within which if the target is present, the camera will not scroll. * If the target moves outside of this area, the camera will begin scrolling in order to follow it. * * The `lerp` values that you can set for a follower target also apply when using a deadzone. * * You can directly set this property to be an instance of a Rectangle. Or, you can use the * `setDeadzone` method for a chainable approach. * * The rectangle you provide can have its dimensions adjusted dynamically, however, please * note that its position is updated every frame, as it is constantly re-centered on the cameras mid point. * * Calling `setDeadzone` with no arguments will reset an active deadzone, as will setting this property * to `null`. * * @name Phaser.Cameras.Scene2D.Camera#deadzone * @type {?Phaser.Geom.Rectangle} * @since 3.11.0 */ this.deadzone = null; /** * Internal follow target reference. * * @name Phaser.Cameras.Scene2D.Camera#_follow * @type {?any} * @private * @default null * @since 3.0.0 */ this._follow = null; }, /** * Sets the Camera dead zone. * * The deadzone is only used when the camera is following a target. * * It defines a rectangular region within which if the target is present, the camera will not scroll. * If the target moves outside of this area, the camera will begin scrolling in order to follow it. * * The deadzone rectangle is re-positioned every frame so that it is centered on the mid-point * of the camera. This allows you to use the object for additional game related checks, such as * testing if an object is within it or not via a Rectangle.contains call. * * The `lerp` values that you can set for a follower target also apply when using a deadzone. * * Calling this method with no arguments will reset an active deadzone. * * @method Phaser.Cameras.Scene2D.Camera#setDeadzone * @since 3.11.0 * * @param {number} [width] - The width of the deadzone rectangle in pixels. If not specified the deadzone is removed. * @param {number} [height] - The height of the deadzone rectangle in pixels. * * @return {this} This Camera instance. */ setDeadzone: function (width, height) { if (width === undefined) { this.deadzone = null; } else { if (this.deadzone) { this.deadzone.width = width; this.deadzone.height = height; } else { this.deadzone = new Rectangle(0, 0, width, height); } if (this._follow) { var originX = this.width / 2; var originY = this.height / 2; var fx = this._follow.x - this.followOffset.x; var fy = this._follow.y - this.followOffset.y; this.midPoint.set(fx, fy); this.scrollX = fx - originX; this.scrollY = fy - originY; } CenterOn(this.deadzone, this.midPoint.x, this.midPoint.y); } return this; }, /** * Fades the Camera in from the given color over the duration specified. * * @method Phaser.Cameras.Scene2D.Camera#fadeIn * @fires Phaser.Cameras.Scene2D.Events#FADE_IN_START * @fires Phaser.Cameras.Scene2D.Events#FADE_IN_COMPLETE * @since 3.3.0 * * @param {number} [duration=1000] - The duration of the effect in milliseconds. * @param {number} [red=0] - The amount to fade the red channel towards. A value between 0 and 255. * @param {number} [green=0] - The amount to fade the green channel towards. A value between 0 and 255. * @param {number} [blue=0] - The amount to fade the blue channel towards. A value between 0 and 255. * @param {function} [callback] - This callback will be invoked every frame for the duration of the effect. * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. * * @return {this} This Camera instance. */ fadeIn: function (duration, red, green, blue, callback, context) { return this.fadeEffect.start(false, duration, red, green, blue, true, callback, context); }, /** * 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 * @fires Phaser.Cameras.Scene2D.Events#FADE_OUT_START * @fires Phaser.Cameras.Scene2D.Events#FADE_OUT_COMPLETE * @since 3.3.0 * * @param {number} [duration=1000] - The duration of the effect in milliseconds. * @param {number} [red=0] - The amount to fade the red channel towards. A value between 0 and 255. * @param {number} [green=0] - The amount to fade the green channel towards. A value between 0 and 255. * @param {number} [blue=0] - The amount to fade the blue channel towards. A value between 0 and 255. * @param {function} [callback] - This callback will be invoked every frame for the duration of the effect. * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. * * @return {this} This Camera instance. */ fadeOut: function (duration, red, green, blue, callback, context) { return this.fadeEffect.start(true, duration, red, green, blue, true, callback, context); }, /** * Fades the Camera from the given color to transparent over the duration specified. * * @method Phaser.Cameras.Scene2D.Camera#fadeFrom * @fires Phaser.Cameras.Scene2D.Events#FADE_IN_START * @fires Phaser.Cameras.Scene2D.Events#FADE_IN_COMPLETE * @since 3.5.0 * * @param {number} [duration=1000] - The duration of the effect in milliseconds. * @param {number} [red=0] - The amount to fade the red channel towards. A value between 0 and 255. * @param {number} [green=0] - The amount to fade the green channel towards. A value between 0 and 255. * @param {number} [blue=0] - The amount to fade the blue channel towards. A value between 0 and 255. * @param {boolean} [force=false] - Force the effect to start immediately, even if already running. * @param {function} [callback] - This callback will be invoked every frame for the duration of the effect. * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. * * @return {this} This Camera instance. */ fadeFrom: function (duration, red, green, blue, force, callback, context) { return this.fadeEffect.start(false, duration, red, green, blue, force, callback, context); }, /** * Fades the Camera from transparent to the given color over the duration specified. * * @method Phaser.Cameras.Scene2D.Camera#fade * @fires Phaser.Cameras.Scene2D.Events#FADE_OUT_START * @fires Phaser.Cameras.Scene2D.Events#FADE_OUT_COMPLETE * @since 3.0.0 * * @param {number} [duration=1000] - The duration of the effect in milliseconds. * @param {number} [red=0] - The amount to fade the red channel towards. A value between 0 and 255. * @param {number} [green=0] - The amount to fade the green channel towards. A value between 0 and 255. * @param {number} [blue=0] - The amount to fade the blue channel towards. A value between 0 and 255. * @param {boolean} [force=false] - Force the effect to start immediately, even if already running. * @param {function} [callback] - This callback will be invoked every frame for the duration of the effect. * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. * * @return {this} This Camera instance. */ fade: function (duration, red, green, blue, force, callback, context) { return this.fadeEffect.start(true, duration, red, green, blue, force, callback, context); }, /** * Flashes the Camera by setting it to the given color immediately and then fading it away again quickly over the duration specified. * * @method Phaser.Cameras.Scene2D.Camera#flash * @fires Phaser.Cameras.Scene2D.Events#FLASH_START * @fires Phaser.Cameras.Scene2D.Events#FLASH_COMPLETE * @since 3.0.0 * * @param {number} [duration=250] - The duration of the effect in milliseconds. * @param {number} [red=255] - The amount to fade the red channel towards. A value between 0 and 255. * @param {number} [green=255] - The amount to fade the green channel towards. A value between 0 and 255. * @param {number} [blue=255] - The amount to fade the blue channel towards. A value between 0 and 255. * @param {boolean} [force=false] - Force the effect to start immediately, even if already running. * @param {function} [callback] - This callback will be invoked every frame for the duration of the effect. * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. * * @return {this} This Camera instance. */ flash: function (duration, red, green, blue, force, callback, context) { return this.flashEffect.start(duration, red, green, blue, force, callback, context); }, /** * Shakes the Camera by the given intensity over the duration specified. * * @method Phaser.Cameras.Scene2D.Camera#shake * @fires Phaser.Cameras.Scene2D.Events#SHAKE_START * @fires Phaser.Cameras.Scene2D.Events#SHAKE_COMPLETE * @since 3.0.0 * * @param {number} [duration=100] - The duration of the effect in milliseconds. * @param {(number|Phaser.Math.Vector2)} [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] - This callback will be invoked every frame for the duration of the effect. * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. * * @return {this} This Camera instance. */ shake: function (duration, intensity, force, callback, context) { return this.shakeEffect.start(duration, intensity, force, callback, context); }, /** * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, * over the duration and with the ease specified. * * @method Phaser.Cameras.Scene2D.Camera#pan * @fires Phaser.Cameras.Scene2D.Events#PAN_START * @fires Phaser.Cameras.Scene2D.Events#PAN_COMPLETE * @since 3.11.0 * * @param {number} x - The destination x coordinate to scroll the center of the Camera viewport to. * @param {number} y - The destination y coordinate to scroll the center of the Camera viewport to. * @param {number} [duration=1000] - The duration of the effect in milliseconds. * @param {(string|function)} [ease='Linear'] - The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. * @param {boolean} [force=false] - Force the pan effect to start immediately, even if already running. * @param {Phaser.Types.Cameras.Scene2D.CameraPanCallback} [callback] - This callback will be invoked every frame for the duration of the effect. * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, * the current camera scroll x coordinate and the current camera scroll y coordinate. * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. * * @return {this} This Camera instance. */ pan: function (x, y, duration, ease, force, callback, context) { return this.panEffect.start(x, y, duration, ease, force, callback, context); }, /** * This effect will rotate the Camera so that the viewport finishes at the given angle in radians, * over the duration and with the ease specified. * * @method Phaser.Cameras.Scene2D.Camera#rotateTo * @since 3.23.0 * * @param {number} radians - The destination angle in radians to rotate the Camera viewport to. If the angle is positive then the rotation is clockwise else anticlockwise * @param {boolean} [shortestPath=false] - If shortest path is set to true the camera will rotate in the quickest direction clockwise or anti-clockwise. * @param {number} [duration=1000] - The duration of the effect in milliseconds. * @param {(string|function)} [ease='Linear'] - The ease to use for the rotation. Can be any of the Phaser Easing constants or a custom function. * @param {boolean} [force=false] - Force the rotation effect to start immediately, even if already running. * @param {CameraRotateCallback} [callback] - This callback will be invoked every frame for the duration of the effect. * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, * the current camera rotation angle in radians. * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. * * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. */ rotateTo: function (radians, shortestPath, duration, ease, force, callback, context) { return this.rotateToEffect.start(radians, shortestPath, duration, ease, force, callback, context); }, /** * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. * * @method Phaser.Cameras.Scene2D.Camera#zoomTo * @fires Phaser.Cameras.Scene2D.Events#ZOOM_START * @fires Phaser.Cameras.Scene2D.Events#ZOOM_COMPLETE * @since 3.11.0 * * @param {number} zoom - The target Camera zoom value. * @param {number} [duration=1000] - The duration of the effect in milliseconds. * @param {(string|function)} [ease='Linear'] - The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. * @param {boolean} [force=false] - Force the pan effect to start immediately, even if already running. * @param {Phaser.Types.Cameras.Scene2D.CameraPanCallback} [callback] - This callback will be invoked every frame for the duration of the effect. * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, * the current camera scroll x coordinate and the current camera scroll y coordinate. * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. * * @return {this} This Camera instance. */ zoomTo: function (zoom, duration, ease, force, callback, context) { return this.zoomEffect.start(zoom, duration, ease, force, callback, context); }, /** * Internal preRender step. * * @method Phaser.Cameras.Scene2D.Camera#preRender * @protected * @since 3.0.0 */ preRender: function () { this.renderList.length = 0; var width = this.width; var height = this.height; var halfWidth = width * 0.5; var halfHeight = height * 0.5; var zoomX = this.zoomX; var zoomY = this.zoomY; var matrix = this.matrix; this.renderRoundPixels = (this.roundPixels && Number.isInteger(zoomX) && Number.isInteger(zoomY)); var originX = width * this.originX; var originY = height * this.originY; var follow = this._follow; var deadzone = this.deadzone; var sx = this.scrollX; var sy = this.scrollY; if (deadzone) { CenterOn(deadzone, this.midPoint.x, this.midPoint.y); } var emitFollowEvent = false; if (follow && !this.panEffect.isRunning) { var lerp = this.lerp; var fx = follow.x - this.followOffset.x; var fy = follow.y - this.followOffset.y; if (deadzone) { if (fx < deadzone.x) { sx = Linear(sx, sx - (deadzone.x - fx), lerp.x); } else if (fx > deadzone.right) { sx = Linear(sx, sx + (fx - deadzone.right), lerp.x); } if (fy < deadzone.y) { sy = Linear(sy, sy - (deadzone.y - fy), lerp.y); } else if (fy > deadzone.bottom) { sy = Linear(sy, sy + (fy - deadzone.bottom), lerp.y); } } else { sx = Linear(sx, fx - originX, lerp.x); sy = Linear(sy, fy - originY, lerp.y); } emitFollowEvent = true; } if (this.roundPixels) { sx = Math.floor(sx); sy = Math.floor(sy); } if (this.useBounds) { sx = this.clampX(sx); sy = this.clampY(sy); } // Values are in pixels and not impacted by zooming the Camera this.scrollX = sx; this.scrollY = sy; // Don't round the midPoint, otherwise it breaks things like smooth zoom var midX = sx + halfWidth; var midY = sy + halfHeight; // The center of the camera, in world space, so taking zoom into account // Basically the pixel value of what it's looking at in the middle of the cam this.midPoint.set(midX, midY); var displayWidth = Math.floor((width / zoomX) + 0.5); var displayHeight = Math.floor((height / zoomY) + 0.5); var vwx = Math.floor((midX - (displayWidth / 2)) + 0.5); var vwy = Math.floor((midY - (displayHeight / 2)) + 0.5); this.worldView.setTo(vwx, vwy, displayWidth, displayHeight); matrix.applyITRS( Math.floor(this.x + originX + 0.5), Math.floor(this.y + originY + 0.5), this.rotation, zoomX, zoomY ); matrix.translate(-originX, -originY); this.shakeEffect.preRender(); if (emitFollowEvent) { this.emit(Events.FOLLOW_UPDATE, this, follow); } }, /** * Sets the linear interpolation value to use when following a target. * * The default values of 1 means the camera will instantly snap to the target coordinates. * A lower value, such as 0.1 means the camera will more slowly track the target, giving * a smooth transition. You can set the horizontal and vertical values independently, and also * adjust this value in real-time during your game. * * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. * * @method Phaser.Cameras.Scene2D.Camera#setLerp * @since 3.9.0 * * @param {number} [x=1] - The amount added to the horizontal linear interpolation of the follow target. * @param {number} [y=1] - The amount added to the vertical linear interpolation of the follow target. * * @return {this} This Camera instance. */ setLerp: function (x, y) { if (x === undefined) { x = 1; } if (y === undefined) { y = x; } this.lerp.set(x, y); return this; }, /** * Sets the horizontal and vertical offset of the camera from its follow target. * The values are subtracted from the targets position during the Cameras update step. * * @method Phaser.Cameras.Scene2D.Camera#setFollowOffset * @since 3.9.0 * * @param {number} [x=0] - The horizontal offset from the camera follow target.x position. * @param {number} [y=0] - The vertical offset from the camera follow target.y position. * * @return {this} This Camera instance. */ setFollowOffset: function (x, y) { if (x === undefined) { x = 0; } if (y === undefined) { y = 0; } this.followOffset.set(x, y); return this; }, /** * Sets the Camera to follow a Game Object. * * When enabled the Camera will automatically adjust its scroll position to keep the target Game Object * in its center. * * You can set the linear interpolation value used in the follow code. * Use low lerp values (such as 0.1) to automatically smooth the camera motion. * * If you find you're getting a slight "jitter" effect when following an object it's probably to do with sub-pixel * rendering of the targets position. This can be rounded by setting the `roundPixels` argument to `true` to * force full pixel rounding rendering. Note that this can still be broken if you have specified a non-integer zoom * value on the camera. So be sure to keep the camera zoom to integers. * * @method Phaser.Cameras.Scene2D.Camera#startFollow * @since 3.0.0 * * @param {(Phaser.GameObjects.GameObject|object)} target - The target for the Camera to follow. * @param {boolean} [roundPixels=false] - Round the camera position to whole integers to avoid sub-pixel rendering? * @param {number} [lerpX=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when horizontally tracking the target. The closer the value to 1, the faster the camera will track. * @param {number} [lerpY=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when vertically tracking the target. The closer the value to 1, the faster the camera will track. * @param {number} [offsetX=0] - The horizontal offset from the camera follow target.x position. * @param {number} [offsetY=0] - The vertical offset from the camera follow target.y position. * * @return {this} This Camera instance. */ startFollow: function (target, roundPixels, lerpX, lerpY, offsetX, offsetY) { if (roundPixels === undefined) { roundPixels = false; } if (lerpX === undefined) { lerpX = 1; } if (lerpY === undefined) { lerpY = lerpX; } if (offsetX === undefined) { offsetX = 0; } if (offsetY === undefined) { offsetY = offsetX; } this._follow = target; this.roundPixels = roundPixels; lerpX = Clamp(lerpX, 0, 1); lerpY = Clamp(lerpY, 0, 1); this.lerp.set(lerpX, lerpY); this.followOffset.set(offsetX, offsetY); var originX = this.width / 2; var originY = this.height / 2; var fx = target.x - offsetX; var fy = target.y - offsetY; this.midPoint.set(fx, fy); this.scrollX = fx - originX; this.scrollY = fy - originY; if (this.useBounds) { this.scrollX = this.clampX(this.scrollX); this.scrollY = this.clampY(this.scrollY); } return this; }, /** * Stops a Camera from following a Game Object, if previously set via `Camera.startFollow`. * * @method Phaser.Cameras.Scene2D.Camera#stopFollow * @since 3.0.0 * * @return {this} This Camera instance. */ stopFollow: function () { this._follow = null; return this; }, /** * 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 {this} This Camera instance. */ resetFX: function () { this.rotateToEffect.reset(); this.panEffect.reset(); this.shakeEffect.reset(); this.flashEffect.reset(); this.fadeEffect.reset(); return this; }, /** * Internal method called automatically by the Camera Manager. * * @method Phaser.Cameras.Scene2D.Camera#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, in ms, elapsed since the last frame. */ update: function (time, delta) { if (this.visible) { this.rotateToEffect.update(time, delta); this.panEffect.update(time, delta); this.zoomEffect.update(time, delta); this.shakeEffect.update(time, delta); this.flashEffect.update(time, delta); this.fadeEffect.update(time, delta); } }, /** * Destroys this Camera instance. You rarely need to call this directly. * * Called by the Camera Manager. If you wish to destroy a Camera please use `CameraManager.remove` as * cameras are stored in a pool, ready for recycling later, and calling this directly will prevent that. * * @method Phaser.Cameras.Scene2D.Camera#destroy * @fires Phaser.Cameras.Scene2D.Events#DESTROY * @since 3.0.0 */ destroy: function () { this.resetFX(); BaseCamera.prototype.destroy.call(this); this._follow = null; this.deadzone = null; } }); module.exports = Camera; /***/ }), /***/ 32743: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Camera = __webpack_require__(38058); var Class = __webpack_require__(83419); var GetFastValue = __webpack_require__(95540); var PluginCache = __webpack_require__(37277); var RectangleContains = __webpack_require__(37303); var ScaleEvents = __webpack_require__(97480); var SceneEvents = __webpack_require__(44594); /** * @classdesc * The Camera Manager is a plugin that belongs to a Scene and is responsible for managing all of the Scene Cameras. * * By default you can access the Camera Manager from within a Scene using `this.cameras`, although this can be changed * in your game config. * * Create new Cameras using the `add` method. Or extend the Camera class with your own addition code and then add * the new Camera in using the `addExisting` method. * * Cameras provide a view into your game world, and can be positioned, rotated, zoomed and scrolled accordingly. * * A Camera consists of two elements: The viewport and the scroll values. * * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are * created the same size as your game, but their position and size can be set to anything. This means if you * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). * * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the * viewport, and changing the viewport has no impact on the scrolling. * * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, * allowing you to filter Game Objects out on a per-Camera basis. The Camera Manager can manage up to 31 unique * 'Game Object ignore capable' Cameras. Any Cameras beyond 31 that you create will all be given a Camera ID of * zero, meaning that they cannot be used for Game Object exclusion. This means if you need your Camera to ignore * Game Objects, make sure it's one of the first 31 created. * * A Camera also has built-in special effects including Fade, Flash, Camera Shake, Pan and Zoom. * * @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; /** * All Cameras created by, or added to, this Camera Manager, will have their `roundPixels` * property set to match this value. By default it is set to match the value set in the * game configuration, but can be changed at any point. Equally, individual cameras can * also be changed as needed. * * @name Phaser.Cameras.Scene2D.CameraManager#roundPixels * @type {boolean} * @since 3.11.0 */ this.roundPixels = scene.sys.game.config.roundPixels; /** * An Array of the Camera objects being managed by this Camera Manager. * The Cameras are updated and rendered in the same order in which they appear in this array. * Do not directly add or remove entries to this array. However, you can move the contents * around the array should you wish to adjust the display order. * * @name Phaser.Cameras.Scene2D.CameraManager#cameras * @type {Phaser.Cameras.Scene2D.Camera[]} * @since 3.0.0 */ this.cameras = []; /** * A handy reference to the 'main' camera. By default this is the first Camera the * Camera Manager creates. You can also set it directly, or use the `makeMain` argument * in the `add` and `addExisting` methods. It allows you to access it from your game: * * ```javascript * var cam = this.cameras.main; * ``` * * Also see the properties `camera1`, `camera2` and so on. * * @name Phaser.Cameras.Scene2D.CameraManager#main * @type {Phaser.Cameras.Scene2D.Camera} * @since 3.0.0 */ this.main; /** * A default un-transformed Camera that doesn't exist on the camera list and doesn't * count towards the total number of cameras being managed. It exists for other * systems, as well as your own code, should they require a basic un-transformed * camera instance from which to calculate a view matrix. * * @name Phaser.Cameras.Scene2D.CameraManager#default * @type {Phaser.Cameras.Scene2D.Camera} * @since 3.17.0 */ this.default; scene.sys.events.once(SceneEvents.BOOT, this.boot, this); scene.sys.events.on(SceneEvents.START, this.start, this); }, /** * This method is called automatically, only once, when the Scene is first created. * Do not invoke it directly. * * @method Phaser.Cameras.Scene2D.CameraManager#boot * @private * @listens Phaser.Scenes.Events#DESTROY * @since 3.5.1 */ boot: function () { var sys = this.systems; if (sys.settings.cameras) { // We have cameras to create this.fromJSON(sys.settings.cameras); } else { // Make one this.add(); } this.main = this.cameras[0]; // Create a default camera this.default = new Camera(0, 0, sys.scale.width, sys.scale.height).setScene(this.scene); sys.game.scale.on(ScaleEvents.RESIZE, this.onResize, this); this.systems.events.once(SceneEvents.DESTROY, this.destroy, this); }, /** * This method is called automatically by the Scene when it is starting up. * It is responsible for creating local systems, properties and listening for Scene events. * Do not invoke it directly. * * @method Phaser.Cameras.Scene2D.CameraManager#start * @private * @listens Phaser.Scenes.Events#UPDATE * @listens Phaser.Scenes.Events#SHUTDOWN * @since 3.5.0 */ start: function () { if (!this.main) { var sys = this.systems; if (sys.settings.cameras) { // We have cameras to create this.fromJSON(sys.settings.cameras); } else { // Make one this.add(); } this.main = this.cameras[0]; } var eventEmitter = this.systems.events; eventEmitter.on(SceneEvents.UPDATE, this.update, this); eventEmitter.once(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** * Adds a new Camera into the Camera Manager. The Camera Manager can support up to 31 different Cameras. * * Each Camera has its own viewport, which controls the size of the Camera and its position within the canvas. * * Use the `Camera.scrollX` and `Camera.scrollY` properties to change where the Camera is looking, or the * Camera methods such as `centerOn`. Cameras also have built in special effects, such as fade, flash, shake, * pan and zoom. * * By default Cameras are transparent and will render anything that they can see based on their `scrollX` * and `scrollY` values. Game Objects can be set to be ignored by a Camera by using the `Camera.ignore` method. * * The Camera will have its `roundPixels` property set to whatever `CameraManager.roundPixels` is. You can change * it after creation if required. * * See the Camera class documentation for more details. * * @method Phaser.Cameras.Scene2D.CameraManager#add * @since 3.0.0 * * @param {number} [x=0] - The horizontal position of the Camera viewport. * @param {number} [y=0] - The vertical position of the Camera viewport. * @param {number} [width] - The width of the Camera viewport. If not given it'll be the game config size. * @param {number} [height] - The height of the Camera viewport. If not given it'll be the game config size. * @param {boolean} [makeMain=false] - Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. * @param {string} [name=''] - The name of the Camera. * * @return {Phaser.Cameras.Scene2D.Camera} The newly created Camera. */ 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.scale.width; } if (height === undefined) { height = this.scene.sys.scale.height; } if (makeMain === undefined) { makeMain = false; } if (name === undefined) { name = ''; } var camera = new Camera(x, y, width, height); camera.setName(name); camera.setScene(this.scene); camera.setRoundPixels(this.roundPixels); camera.id = this.getNextID(); this.cameras.push(camera); if (makeMain) { this.main = camera; } return camera; }, /** * Adds an existing Camera into the Camera Manager. * * The Camera should either be a `Phaser.Cameras.Scene2D.Camera` instance, or a class that extends from it. * * The Camera will have its `roundPixels` property set to whatever `CameraManager.roundPixels` is. You can change * it after addition if required. * * The Camera will be assigned an ID, which is used for Game Object exclusion and then added to the * manager. As long as it doesn't already exist in the manager it will be added then returned. * * If this method returns `null` then the Camera already exists in this Camera Manager. * * @method Phaser.Cameras.Scene2D.CameraManager#addExisting * @since 3.0.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to be added to the Camera Manager. * @param {boolean} [makeMain=false] - Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. * * @return {?Phaser.Cameras.Scene2D.Camera} The Camera that was added to the Camera Manager, or `null` if it couldn't be added. */ addExisting: function (camera, makeMain) { if (makeMain === undefined) { makeMain = false; } var index = this.cameras.indexOf(camera); if (index === -1) { camera.id = this.getNextID(); camera.setRoundPixels(this.roundPixels); this.cameras.push(camera); if (makeMain) { this.main = camera; } return camera; } return null; }, /** * Gets the next available Camera ID number. * * The Camera Manager supports up to 31 unique cameras, after which the ID returned will always be zero. * You can create additional cameras beyond 31, but they cannot be used for Game Object exclusion. * * @method Phaser.Cameras.Scene2D.CameraManager#getNextID * @private * @since 3.11.0 * * @return {number} The next available Camera ID, or 0 if they're all already in use. */ getNextID: function () { var cameras = this.cameras; var testID = 1; // Find the first free camera ID we can use for (var t = 0; t < 32; t++) { var found = false; for (var i = 0; i < cameras.length; i++) { var camera = cameras[i]; if (camera && camera.id === testID) { found = true; continue; } } if (found) { testID = testID << 1; } else { return testID; } } return 0; }, /** * Gets the total number of Cameras in this Camera Manager. * * If the optional `isVisible` argument is set it will only count Cameras that are currently visible. * * @method Phaser.Cameras.Scene2D.CameraManager#getTotal * @since 3.11.0 * * @param {boolean} [isVisible=false] - Set the `true` to only include visible Cameras in the total. * * @return {number} The total number of Cameras in this Camera Manager. */ getTotal: function (isVisible) { if (isVisible === undefined) { isVisible = false; } var total = 0; var cameras = this.cameras; for (var i = 0; i < cameras.length; i++) { var camera = cameras[i]; if (!isVisible || (isVisible && camera.visible)) { total++; } } return total; }, /** * Populates this Camera Manager based on the given configuration object, or an array of config objects. * * See the `Phaser.Types.Cameras.Scene2D.CameraConfig` documentation for details of the object structure. * * @method Phaser.Cameras.Scene2D.CameraManager#fromJSON * @since 3.0.0 * * @param {(Phaser.Types.Cameras.Scene2D.CameraConfig|Phaser.Types.Cameras.Scene2D.CameraConfig[])} config - A Camera configuration object, or an array of them, to be added to this Camera Manager. * * @return {this} This Camera Manager instance. */ fromJSON: function (config) { if (!Array.isArray(config)) { config = [ config ]; } var gameWidth = this.scene.sys.scale.width; var gameHeight = this.scene.sys.scale.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); camera.visible = GetFastValue(cameraConfig, 'visible', true); // 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; }, /** * Gets a Camera based on its name. * * Camera names are optional and don't have to be set, so this method is only of any use if you * have given your Cameras unique names. * * @method Phaser.Cameras.Scene2D.CameraManager#getCamera * @since 3.0.0 * * @param {string} name - The name of the Camera. * * @return {?Phaser.Cameras.Scene2D.Camera} The first Camera with a name matching the given string, otherwise `null`. */ getCamera: function (name) { var cameras = this.cameras; for (var i = 0; i < cameras.length; i++) { if (cameras[i].name === name) { return cameras[i]; } } return null; }, /** * Returns an array of all cameras below the given Pointer. * * The first camera in the array is the top-most camera in the camera list. * * @method Phaser.Cameras.Scene2D.CameraManager#getCamerasBelowPointer * @since 3.10.0 * * @param {Phaser.Input.Pointer} pointer - The Pointer to check against. * * @return {Phaser.Cameras.Scene2D.Camera[]} An array of cameras below the Pointer. */ getCamerasBelowPointer: function (pointer) { var cameras = this.cameras; var x = pointer.x; var y = pointer.y; var output = []; for (var i = 0; i < cameras.length; i++) { var camera = cameras[i]; if (camera.visible && camera.inputEnabled && RectangleContains(camera, x, y)) { // So the top-most camera is at the top of the search array output.unshift(camera); } } return output; }, /** * Removes the given Camera, or an array of Cameras, from this Camera Manager. * * If found in the Camera Manager it will be immediately removed from the local cameras array. * If also currently the 'main' camera, 'main' will be reset to be camera 0. * * The removed Cameras are automatically destroyed if the `runDestroy` argument is `true`, which is the default. * If you wish to re-use the cameras then set this to `false`, but know that they will retain their references * and internal data until destroyed or re-added to a Camera Manager. * * @method Phaser.Cameras.Scene2D.CameraManager#remove * @since 3.0.0 * * @param {(Phaser.Cameras.Scene2D.Camera|Phaser.Cameras.Scene2D.Camera[])} camera - The Camera, or an array of Cameras, to be removed from this Camera Manager. * @param {boolean} [runDestroy=true] - Automatically call `Camera.destroy` on each Camera removed from this Camera Manager. * * @return {number} The total number of Cameras removed. */ remove: function (camera, runDestroy) { if (runDestroy === undefined) { runDestroy = true; } if (!Array.isArray(camera)) { camera = [ camera ]; } var total = 0; var cameras = this.cameras; for (var i = 0; i < camera.length; i++) { var index = cameras.indexOf(camera[i]); if (index !== -1) { if (runDestroy) { cameras[index].destroy(); } else { cameras[index].renderList = []; } cameras.splice(index, 1); total++; } } if (!this.main && cameras[0]) { this.main = cameras[0]; } return total; }, /** * The internal render method. This is called automatically by the Scene and should not be invoked directly. * * It will iterate through all local cameras and render them in turn, as long as they're visible and have * an alpha level > 0. * * @method Phaser.Cameras.Scene2D.CameraManager#render * @protected * @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.DisplayList} displayList - The Display List for the Scene. */ render: function (renderer, displayList) { var scene = this.scene; var cameras = this.cameras; for (var i = 0; i < cameras.length; i++) { var camera = cameras[i]; if (camera.visible && camera.alpha > 0) { camera.preRender(); var visibleChildren = this.getVisibleChildren(displayList.getChildren(), camera); renderer.render(scene, visibleChildren, camera); } } }, /** * Takes an array of Game Objects and a Camera and returns a new array * containing only those Game Objects that pass the `willRender` test * against the given Camera. * * @method Phaser.Cameras.Scene2D.CameraManager#getVisibleChildren * @since 3.50.0 * * @param {Phaser.GameObjects.GameObject[]} children - An array of Game Objects to be checked against the camera. * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to filter the Game Objects against. * * @return {Phaser.GameObjects.GameObject[]} A filtered list of only Game Objects within the Scene that will render against the given Camera. */ getVisibleChildren: function (children, camera) { return children.filter(function (child) { return child.willRender(camera); }); }, /** * Resets this Camera Manager. * * This will iterate through all current Cameras, destroying them all, then it will reset the * cameras array, reset the ID counter and create 1 new single camera using the default values. * * @method Phaser.Cameras.Scene2D.CameraManager#resetAll * @since 3.0.0 * * @return {Phaser.Cameras.Scene2D.Camera} The freshly created main Camera. */ resetAll: function () { for (var i = 0; i < this.cameras.length; i++) { this.cameras[i].destroy(); } this.cameras = []; this.main = this.add(); return this.main; }, /** * The main update loop. Called automatically when the Scene steps. * * @method Phaser.Cameras.Scene2D.CameraManager#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, in ms, elapsed since the last frame. */ update: function (time, delta) { for (var i = 0; i < this.cameras.length; i++) { this.cameras[i].update(time, delta); } }, /** * The event handler that manages the `resize` event dispatched by the Scale Manager. * * @method Phaser.Cameras.Scene2D.CameraManager#onResize * @since 3.18.0 * * @param {Phaser.Structs.Size} gameSize - The default Game Size object. This is the un-modified game dimensions. * @param {Phaser.Structs.Size} baseSize - The base Size object. The game dimensions. The canvas width / height values match this. */ onResize: function (gameSize, baseSize, displaySize, previousWidth, previousHeight) { for (var i = 0; i < this.cameras.length; i++) { var cam = this.cameras[i]; // if camera is at 0x0 and was the size of the previous game size, then we can safely assume it // should be updated to match the new game size too if (cam._x === 0 && cam._y === 0 && cam._width === previousWidth && cam._height === previousHeight) { cam.setSize(baseSize.width, baseSize.height); } } }, /** * 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; i < this.cameras.length; i++) { this.cameras[i].setSize(width, height); } }, /** * The Scene that owns this plugin is shutting down. * We need to kill and reset all internal properties as well as stop listening to Scene events. * * @method Phaser.Cameras.Scene2D.CameraManager#shutdown * @private * @since 3.0.0 */ shutdown: function () { this.main = undefined; for (var i = 0; i < this.cameras.length; i++) { this.cameras[i].destroy(); } this.cameras = []; var eventEmitter = this.systems.events; eventEmitter.off(SceneEvents.UPDATE, this.update, this); eventEmitter.off(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** * The Scene that owns this plugin is being destroyed. * We need to shutdown and then kill off all external references. * * @method Phaser.Cameras.Scene2D.CameraManager#destroy * @private * @since 3.0.0 */ destroy: function () { this.shutdown(); this.default.destroy(); this.systems.events.off(SceneEvents.START, this.start, this); this.systems.events.off(SceneEvents.DESTROY, this.destroy, this); this.systems.game.scale.off(ScaleEvents.RESIZE, this.onResize, this); this.scene = null; this.systems = null; } }); PluginCache.register('CameraManager', CameraManager, 'cameras'); module.exports = CameraManager; /***/ }), /***/ 5020: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Clamp = __webpack_require__(45319); var Class = __webpack_require__(83419); var Events = __webpack_require__(19715); /** * @classdesc * A Camera Fade effect. * * This effect will fade the camera viewport to the given color, over the duration specified. * * Only the camera viewport is faded. None of the objects it is displaying are impacted, i.e. their colors do * not change. * * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, * which is invoked each frame for the duration of the effect, if required. * * @class Fade * @memberof Phaser.Cameras.Scene2D.Effects * @constructor * @since 3.5.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon. */ var Fade = new Class({ initialize: function Fade (camera) { /** * The Camera this effect belongs to. * * @name Phaser.Cameras.Scene2D.Effects.Fade#camera * @type {Phaser.Cameras.Scene2D.Camera} * @readonly * @since 3.5.0 */ this.camera = camera; /** * Is this effect actively running? * * @name Phaser.Cameras.Scene2D.Effects.Fade#isRunning * @type {boolean} * @readonly * @default false * @since 3.5.0 */ this.isRunning = false; /** * Has this effect finished running? * * This is different from `isRunning` because it remains set to `true` when the effect is over, * until the effect is either reset or started again. * * @name Phaser.Cameras.Scene2D.Effects.Fade#isComplete * @type {boolean} * @readonly * @default false * @since 3.5.0 */ this.isComplete = false; /** * The direction of the fade. * `true` = fade out (transparent to color), `false` = fade in (color to transparent) * * @name Phaser.Cameras.Scene2D.Effects.Fade#direction * @type {boolean} * @readonly * @since 3.5.0 */ this.direction = true; /** * The duration of the effect, in milliseconds. * * @name Phaser.Cameras.Scene2D.Effects.Fade#duration * @type {number} * @readonly * @default 0 * @since 3.5.0 */ this.duration = 0; /** * The value of the red color channel the camera will use for the fade effect. * A value between 0 and 255. * * @name Phaser.Cameras.Scene2D.Effects.Fade#red * @type {number} * @private * @since 3.5.0 */ this.red = 0; /** * The value of the green color channel the camera will use for the fade effect. * A value between 0 and 255. * * @name Phaser.Cameras.Scene2D.Effects.Fade#green * @type {number} * @private * @since 3.5.0 */ this.green = 0; /** * The value of the blue color channel the camera will use for the fade effect. * A value between 0 and 255. * * @name Phaser.Cameras.Scene2D.Effects.Fade#blue * @type {number} * @private * @since 3.5.0 */ this.blue = 0; /** * The value of the alpha channel used during the fade effect. * A value between 0 and 1. * * @name Phaser.Cameras.Scene2D.Effects.Fade#alpha * @type {number} * @private * @since 3.5.0 */ this.alpha = 0; /** * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. * * @name Phaser.Cameras.Scene2D.Effects.Fade#progress * @type {number} * @since 3.5.0 */ this.progress = 0; /** * Effect elapsed timer. * * @name Phaser.Cameras.Scene2D.Effects.Fade#_elapsed * @type {number} * @private * @since 3.5.0 */ this._elapsed = 0; /** * This callback is invoked every frame for the duration of the effect. * * @name Phaser.Cameras.Scene2D.Effects.Fade#_onUpdate * @type {?Phaser.Types.Cameras.Scene2D.CameraFadeCallback} * @private * @default null * @since 3.5.0 */ this._onUpdate; /** * On Complete callback scope. * * @name Phaser.Cameras.Scene2D.Effects.Fade#_onUpdateScope * @type {any} * @private * @since 3.5.0 */ this._onUpdateScope; }, /** * Fades the Camera to or from the given color over the duration specified. * * @method Phaser.Cameras.Scene2D.Effects.Fade#start * @fires Phaser.Cameras.Scene2D.Events#FADE_IN_START * @fires Phaser.Cameras.Scene2D.Events#FADE_OUT_START * @since 3.5.0 * * @param {boolean} [direction=true] - The direction of the fade. `true` = fade out (transparent to color), `false` = fade in (color to transparent) * @param {number} [duration=1000] - The duration of the effect in milliseconds. * @param {number} [red=0] - The amount to fade the red channel towards. A value between 0 and 255. * @param {number} [green=0] - The amount to fade the green channel towards. A value between 0 and 255. * @param {number} [blue=0] - The amount to fade the blue channel towards. A value between 0 and 255. * @param {boolean} [force=false] - Force the effect to start immediately, even if already running. * @param {Phaser.Types.Cameras.Scene2D.CameraFadeCallback} [callback] - This callback will be invoked every frame for the duration of the effect. * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. * * @return {Phaser.Cameras.Scene2D.Camera} The Camera on which the effect was started. */ start: function (direction, duration, red, green, blue, force, callback, context) { if (direction === undefined) { direction = true; } if (duration === undefined) { duration = 1000; } 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 (context === undefined) { context = this.camera.scene; } if (!force && this.isRunning) { return this.camera; } this.isRunning = true; this.isComplete = false; this.duration = duration; this.direction = direction; this.progress = 0; this.red = red; this.green = green; this.blue = blue; this.alpha = (direction) ? Number.MIN_VALUE : 1; this._elapsed = 0; this._onUpdate = callback; this._onUpdateScope = context; var eventName = (direction) ? Events.FADE_OUT_START : Events.FADE_IN_START; this.camera.emit(eventName, this.camera, this, duration, red, green, blue); return this.camera; }, /** * The main update loop for this effect. Called automatically by the Camera. * * @method Phaser.Cameras.Scene2D.Effects.Fade#update * @since 3.5.0 * * @param {number} 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.isRunning) { return; } this._elapsed += delta; this.progress = Clamp(this._elapsed / this.duration, 0, 1); if (this._onUpdate) { this._onUpdate.call(this._onUpdateScope, this.camera, this.progress); } if (this._elapsed < this.duration) { this.alpha = (this.direction) ? this.progress : 1 - this.progress; } else { this.alpha = (this.direction) ? 1 : 0; this.effectComplete(); } }, /** * Called internally by the Canvas Renderer. * * @method Phaser.Cameras.Scene2D.Effects.Fade#postRenderCanvas * @since 3.5.0 * * @param {CanvasRenderingContext2D} ctx - The Canvas context to render to. * * @return {boolean} `true` if the effect drew to the renderer, otherwise `false`. */ postRenderCanvas: function (ctx) { if (!this.isRunning && !this.isComplete) { return false; } var camera = this.camera; ctx.fillStyle = 'rgba(' + this.red + ',' + this.green + ',' + this.blue + ',' + this.alpha + ')'; ctx.fillRect(camera.x, camera.y, camera.width, camera.height); return true; }, /** * Called internally by the WebGL Renderer. * * @method Phaser.Cameras.Scene2D.Effects.Fade#postRenderWebGL * @since 3.5.0 * * @param {Phaser.Renderer.WebGL.Pipelines.MultiPipeline} pipeline - The WebGL Pipeline to render to. Must provide the `drawFillRect` method. * @param {function} getTintFunction - A function that will return the gl safe tint colors. * * @return {boolean} `true` if the effect drew to the renderer, otherwise `false`. */ postRenderWebGL: function (pipeline, getTintFunction) { if (!this.isRunning && !this.isComplete) { return false; } var camera = this.camera; var red = this.red / 255; var green = this.green / 255; var blue = this.blue / 255; pipeline.drawFillRect( camera.x, camera.y, camera.width, camera.height, getTintFunction(blue, green, red, 1), this.alpha ); return true; }, /** * Called internally when the effect completes. * * @method Phaser.Cameras.Scene2D.Effects.Fade#effectComplete * @fires Phaser.Cameras.Scene2D.Events#FADE_IN_COMPLETE * @fires Phaser.Cameras.Scene2D.Events#FADE_OUT_COMPLETE * @since 3.5.0 */ effectComplete: function () { this._onUpdate = null; this._onUpdateScope = null; this.isRunning = false; this.isComplete = true; var eventName = (this.direction) ? Events.FADE_OUT_COMPLETE : Events.FADE_IN_COMPLETE; this.camera.emit(eventName, this.camera, this); }, /** * Resets this camera effect. * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. * * @method Phaser.Cameras.Scene2D.Effects.Fade#reset * @since 3.5.0 */ reset: function () { this.isRunning = false; this.isComplete = false; this._onUpdate = null; this._onUpdateScope = null; }, /** * Destroys this effect, releasing it from the Camera. * * @method Phaser.Cameras.Scene2D.Effects.Fade#destroy * @since 3.5.0 */ destroy: function () { this.reset(); this.camera = null; } }); module.exports = Fade; /***/ }), /***/ 10662: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Clamp = __webpack_require__(45319); var Class = __webpack_require__(83419); var Events = __webpack_require__(19715); /** * @classdesc * A Camera Flash effect. * * This effect will flash the camera viewport to the given color, over the duration specified. * * Only the camera viewport is flashed. None of the objects it is displaying are impacted, i.e. their colors do * not change. * * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, * which is invoked each frame for the duration of the effect, if required. * * @class Flash * @memberof Phaser.Cameras.Scene2D.Effects * @constructor * @since 3.5.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon. */ var Flash = new Class({ initialize: function Flash (camera) { /** * The Camera this effect belongs to. * * @name Phaser.Cameras.Scene2D.Effects.Flash#camera * @type {Phaser.Cameras.Scene2D.Camera} * @readonly * @since 3.5.0 */ this.camera = camera; /** * Is this effect actively running? * * @name Phaser.Cameras.Scene2D.Effects.Flash#isRunning * @type {boolean} * @readonly * @default false * @since 3.5.0 */ this.isRunning = false; /** * The duration of the effect, in milliseconds. * * @name Phaser.Cameras.Scene2D.Effects.Flash#duration * @type {number} * @readonly * @default 0 * @since 3.5.0 */ this.duration = 0; /** * The value of the red color channel the camera will use for the flash effect. * A value between 0 and 255. * * @name Phaser.Cameras.Scene2D.Effects.Flash#red * @type {number} * @private * @since 3.5.0 */ this.red = 0; /** * The value of the green color channel the camera will use for the flash effect. * A value between 0 and 255. * * @name Phaser.Cameras.Scene2D.Effects.Flash#green * @type {number} * @private * @since 3.5.0 */ this.green = 0; /** * The value of the blue color channel the camera will use for the flash effect. * A value between 0 and 255. * * @name Phaser.Cameras.Scene2D.Effects.Flash#blue * @type {number} * @private * @since 3.5.0 */ this.blue = 0; /** * The value of the alpha channel used during the flash effect. * A value between 0 and 1. * * @name Phaser.Cameras.Scene2D.Effects.Flash#alpha * @type {number} * @since 3.5.0 */ this.alpha = 1; /** * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. * * @name Phaser.Cameras.Scene2D.Effects.Flash#progress * @type {number} * @since 3.5.0 */ this.progress = 0; /** * Effect elapsed timer. * * @name Phaser.Cameras.Scene2D.Effects.Flash#_elapsed * @type {number} * @private * @since 3.5.0 */ this._elapsed = 0; /** * This is an internal copy of the initial value of `this.alpha`, used to calculate the current alpha value of the fade effect. * * @name Phaser.Cameras.Scene2D.Effects.Flash#_alpha * @type {number} * @private * @readonly * @since 3.60.0 */ this._alpha; /** * This callback is invoked every frame for the duration of the effect. * * @name Phaser.Cameras.Scene2D.Effects.Flash#_onUpdate * @type {?Phaser.Types.Cameras.Scene2D.CameraFlashCallback} * @private * @default null * @since 3.5.0 */ this._onUpdate; /** * On Complete callback scope. * * @name Phaser.Cameras.Scene2D.Effects.Flash#_onUpdateScope * @type {any} * @private * @since 3.5.0 */ this._onUpdateScope; }, /** * Flashes the Camera to or from the given color over the duration specified. * * @method Phaser.Cameras.Scene2D.Effects.Flash#start * @fires Phaser.Cameras.Scene2D.Events#FLASH_START * @fires Phaser.Cameras.Scene2D.Events#FLASH_COMPLETE * @since 3.5.0 * * @param {number} [duration=250] - The duration of the effect in milliseconds. * @param {number} [red=255] - The amount to flash the red channel towards. A value between 0 and 255. * @param {number} [green=255] - The amount to flash the green channel towards. A value between 0 and 255. * @param {number} [blue=255] - The amount to flash the blue channel towards. A value between 0 and 255. * @param {boolean} [force=false] - Force the effect to start immediately, even if already running. * @param {Phaser.Types.Cameras.Scene2D.CameraFlashCallback} [callback] - This callback will be invoked every frame for the duration of the effect. * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. * * @return {Phaser.Cameras.Scene2D.Camera} The Camera on which the effect was started. */ start: function (duration, red, green, blue, force, callback, context) { if (duration === undefined) { duration = 250; } if (red === undefined) { red = 255; } if (green === undefined) { green = 255; } if (blue === undefined) { blue = 255; } if (force === undefined) { force = false; } if (callback === undefined) { callback = null; } if (context === undefined) { context = this.camera.scene; } if (!force && this.isRunning) { return this.camera; } this.isRunning = true; this.duration = duration; this.progress = 0; this.red = red; this.green = green; this.blue = blue; this._alpha = this.alpha; this._elapsed = 0; this._onUpdate = callback; this._onUpdateScope = context; this.camera.emit(Events.FLASH_START, this.camera, this, duration, red, green, blue); return this.camera; }, /** * The main update loop for this effect. Called automatically by the Camera. * * @method Phaser.Cameras.Scene2D.Effects.Flash#update * @since 3.5.0 * * @param {number} 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.isRunning) { return; } this._elapsed += delta; this.progress = Clamp(this._elapsed / this.duration, 0, 1); if (this._onUpdate) { this._onUpdate.call(this._onUpdateScope, this.camera, this.progress); } if (this._elapsed < this.duration) { this.alpha = this._alpha * (1 - this.progress); } else { this.effectComplete(); } }, /** * Called internally by the Canvas Renderer. * * @method Phaser.Cameras.Scene2D.Effects.Flash#postRenderCanvas * @since 3.5.0 * * @param {CanvasRenderingContext2D} ctx - The Canvas context to render to. * * @return {boolean} `true` if the effect drew to the renderer, otherwise `false`. */ postRenderCanvas: function (ctx) { if (!this.isRunning) { return false; } var camera = this.camera; ctx.fillStyle = 'rgba(' + this.red + ',' + this.green + ',' + this.blue + ',' + this.alpha + ')'; ctx.fillRect(camera.x, camera.y, camera.width, camera.height); return true; }, /** * Called internally by the WebGL Renderer. * * @method Phaser.Cameras.Scene2D.Effects.Flash#postRenderWebGL * @since 3.5.0 * * @param {Phaser.Renderer.WebGL.Pipelines.MultiPipeline} pipeline - The WebGL Pipeline to render to. Must provide the `drawFillRect` method. * @param {function} getTintFunction - A function that will return the gl safe tint colors. * * @return {boolean} `true` if the effect drew to the renderer, otherwise `false`. */ postRenderWebGL: function (pipeline, getTintFunction) { if (!this.isRunning) { return false; } var camera = this.camera; var red = this.red / 255; var green = this.green / 255; var blue = this.blue / 255; pipeline.drawFillRect( camera.x, camera.y, camera.width, camera.height, getTintFunction(blue, green, red, 1), this.alpha ); return true; }, /** * Called internally when the effect completes. * * @method Phaser.Cameras.Scene2D.Effects.Flash#effectComplete * @fires Phaser.Cameras.Scene2D.Events#FLASH_COMPLETE * @since 3.5.0 */ effectComplete: function () { this.alpha = this._alpha; this._onUpdate = null; this._onUpdateScope = null; this.isRunning = false; this.camera.emit(Events.FLASH_COMPLETE, this.camera, this); }, /** * Resets this camera effect. * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. * * @method Phaser.Cameras.Scene2D.Effects.Flash#reset * @since 3.5.0 */ reset: function () { this.isRunning = false; this._onUpdate = null; this._onUpdateScope = null; }, /** * Destroys this effect, releasing it from the Camera. * * @method Phaser.Cameras.Scene2D.Effects.Flash#destroy * @since 3.5.0 */ destroy: function () { this.reset(); this.camera = null; } }); module.exports = Flash; /***/ }), /***/ 20359: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Clamp = __webpack_require__(45319); var Class = __webpack_require__(83419); var EaseMap = __webpack_require__(62640); var Events = __webpack_require__(19715); var Vector2 = __webpack_require__(26099); /** * @classdesc * A Camera Pan effect. * * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, * over the duration and with the ease specified. * * Only the camera scroll is moved. None of the objects it is displaying are impacted, i.e. their positions do * not change. * * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, * which is invoked each frame for the duration of the effect if required. * * @class Pan * @memberof Phaser.Cameras.Scene2D.Effects * @constructor * @since 3.11.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon. */ var Pan = new Class({ initialize: function Pan (camera) { /** * The Camera this effect belongs to. * * @name Phaser.Cameras.Scene2D.Effects.Pan#camera * @type {Phaser.Cameras.Scene2D.Camera} * @readonly * @since 3.11.0 */ this.camera = camera; /** * Is this effect actively running? * * @name Phaser.Cameras.Scene2D.Effects.Pan#isRunning * @type {boolean} * @readonly * @default false * @since 3.11.0 */ this.isRunning = false; /** * The duration of the effect, in milliseconds. * * @name Phaser.Cameras.Scene2D.Effects.Pan#duration * @type {number} * @readonly * @default 0 * @since 3.11.0 */ this.duration = 0; /** * The starting scroll coordinates to pan the camera from. * * @name Phaser.Cameras.Scene2D.Effects.Pan#source * @type {Phaser.Math.Vector2} * @since 3.11.0 */ this.source = new Vector2(); /** * The constantly updated value based on zoom. * * @name Phaser.Cameras.Scene2D.Effects.Pan#current * @type {Phaser.Math.Vector2} * @since 3.11.0 */ this.current = new Vector2(); /** * The destination scroll coordinates to pan the camera to. * * @name Phaser.Cameras.Scene2D.Effects.Pan#destination * @type {Phaser.Math.Vector2} * @since 3.11.0 */ this.destination = new Vector2(); /** * The ease function to use during the pan. * * @name Phaser.Cameras.Scene2D.Effects.Pan#ease * @type {function} * @since 3.11.0 */ this.ease; /** * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. * * @name Phaser.Cameras.Scene2D.Effects.Pan#progress * @type {number} * @since 3.11.0 */ this.progress = 0; /** * Effect elapsed timer. * * @name Phaser.Cameras.Scene2D.Effects.Pan#_elapsed * @type {number} * @private * @since 3.11.0 */ this._elapsed = 0; /** * This callback is invoked every frame for the duration of the effect. * * @name Phaser.Cameras.Scene2D.Effects.Pan#_onUpdate * @type {?Phaser.Types.Cameras.Scene2D.CameraPanCallback} * @private * @default null * @since 3.11.0 */ this._onUpdate; /** * On Complete callback scope. * * @name Phaser.Cameras.Scene2D.Effects.Pan#_onUpdateScope * @type {any} * @private * @since 3.11.0 */ this._onUpdateScope; }, /** * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, * over the duration and with the ease specified. * * @method Phaser.Cameras.Scene2D.Effects.Pan#start * @fires Phaser.Cameras.Scene2D.Events#PAN_START * @fires Phaser.Cameras.Scene2D.Events#PAN_COMPLETE * @since 3.11.0 * * @param {number} x - The destination x coordinate to scroll the center of the Camera viewport to. * @param {number} y - The destination y coordinate to scroll the center of the Camera viewport to. * @param {number} [duration=1000] - The duration of the effect in milliseconds. * @param {(string|function)} [ease='Linear'] - The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. * @param {boolean} [force=false] - Force the pan effect to start immediately, even if already running. * @param {Phaser.Types.Cameras.Scene2D.CameraPanCallback} [callback] - This callback will be invoked every frame for the duration of the effect. * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, * the current camera scroll x coordinate and the current camera scroll y coordinate. * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. * * @return {Phaser.Cameras.Scene2D.Camera} The Camera on which the effect was started. */ start: function (x, y, duration, ease, force, callback, context) { if (duration === undefined) { duration = 1000; } if (ease === undefined) { ease = EaseMap.Linear; } if (force === undefined) { force = false; } if (callback === undefined) { callback = null; } if (context === undefined) { context = this.camera.scene; } var cam = this.camera; if (!force && this.isRunning) { return cam; } this.isRunning = true; this.duration = duration; this.progress = 0; // Starting from this.source.set(cam.scrollX, cam.scrollY); // Destination this.destination.set(x, y); // Zoom factored version cam.getScroll(x, y, this.current); // Using this ease if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) { this.ease = EaseMap[ease]; } else if (typeof ease === 'function') { this.ease = ease; } this._elapsed = 0; this._onUpdate = callback; this._onUpdateScope = context; this.camera.emit(Events.PAN_START, this.camera, this, duration, x, y); return cam; }, /** * The main update loop for this effect. Called automatically by the Camera. * * @method Phaser.Cameras.Scene2D.Effects.Pan#update * @since 3.11.0 * * @param {number} 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.isRunning) { return; } this._elapsed += delta; var progress = Clamp(this._elapsed / this.duration, 0, 1); this.progress = progress; var cam = this.camera; if (this._elapsed < this.duration) { var v = this.ease(progress); cam.getScroll(this.destination.x, this.destination.y, this.current); var x = this.source.x + ((this.current.x - this.source.x) * v); var y = this.source.y + ((this.current.y - this.source.y) * v); cam.setScroll(x, y); if (this._onUpdate) { this._onUpdate.call(this._onUpdateScope, cam, progress, x, y); } } else { cam.centerOn(this.destination.x, this.destination.y); if (this._onUpdate) { this._onUpdate.call(this._onUpdateScope, cam, progress, cam.scrollX, cam.scrollY); } this.effectComplete(); } }, /** * Called internally when the effect completes. * * @method Phaser.Cameras.Scene2D.Effects.Pan#effectComplete * @fires Phaser.Cameras.Scene2D.Events#PAN_COMPLETE * @since 3.11.0 */ effectComplete: function () { this._onUpdate = null; this._onUpdateScope = null; this.isRunning = false; this.camera.emit(Events.PAN_COMPLETE, this.camera, this); }, /** * Resets this camera effect. * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. * * @method Phaser.Cameras.Scene2D.Effects.Pan#reset * @since 3.11.0 */ reset: function () { this.isRunning = false; this._onUpdate = null; this._onUpdateScope = null; }, /** * Destroys this effect, releasing it from the Camera. * * @method Phaser.Cameras.Scene2D.Effects.Pan#destroy * @since 3.11.0 */ destroy: function () { this.reset(); this.camera = null; this.source = null; this.destination = null; } }); module.exports = Pan; /***/ }), /***/ 34208: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Jason Nicholls * @copyright 2018 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ var Clamp = __webpack_require__(45319); var Class = __webpack_require__(83419); var Events = __webpack_require__(19715); var EaseMap = __webpack_require__(62640); /** * @classdesc * A Camera Rotate effect. * * This effect will rotate the Camera so that the its viewport finishes at the given angle in radians, * over the duration and with the ease specified. * * Camera rotation always takes place based on the Camera viewport. By default, rotation happens * in the center of the viewport. You can adjust this with the `originX` and `originY` properties. * * Rotation influences the rendering of _all_ Game Objects visible by this Camera. However, it does not * rotate the Camera viewport itself, which always remains an axis-aligned rectangle. * * Only the camera is rotates. None of the objects it is displaying are impacted, i.e. their positions do * not change. * * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, * which is invoked each frame for the duration of the effect if required. * * @class RotateTo * @memberof Phaser.Cameras.Scene2D.Effects * @constructor * @since 3.23.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon. */ var RotateTo = new Class({ initialize: function RotateTo (camera) { /** * The Camera this effect belongs to. * * @name Phaser.Cameras.Scene2D.Effects.RotateTo#camera * @type {Phaser.Cameras.Scene2D.Camera} * @readonly * @since 3.23.0 */ this.camera = camera; /** * Is this effect actively running? * * @name Phaser.Cameras.Scene2D.Effects.RotateTo#isRunning * @type {boolean} * @readonly * @default false * @since 3.23.0 */ this.isRunning = false; /** * The duration of the effect, in milliseconds. * * @name Phaser.Cameras.Scene2D.Effects.RotateTo#duration * @type {number} * @readonly * @default 0 * @since 3.23.0 */ this.duration = 0; /** * The starting angle to rotate the camera from. * * @name Phaser.Cameras.Scene2D.Effects.RotateTo#source * @type {number} * @since 3.23.0 */ this.source = 0; /** * The constantly updated value based on the force. * * @name Phaser.Cameras.Scene2D.Effects.RotateTo#current * @type {number} * @since 3.23.0 */ this.current = 0; /** * The destination angle in radians to rotate the camera to. * * @name Phaser.Cameras.Scene2D.Effects.RotateTo#destination * @type {number} * @since 3.23.0 */ this.destination = 0; /** * The ease function to use during the Rotate. * * @name Phaser.Cameras.Scene2D.Effects.RotateTo#ease * @type {function} * @since 3.23.0 */ this.ease; /** * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. * * @name Phaser.Cameras.Scene2D.Effects.RotateTo#progress * @type {number} * @since 3.23.0 */ this.progress = 0; /** * Effect elapsed timer. * * @name Phaser.Cameras.Scene2D.Effects.RotateTo#_elapsed * @type {number} * @private * @since 3.23.0 */ this._elapsed = 0; /** * @callback CameraRotateCallback * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running. * @param {number} progress - The progress of the effect. A value between 0 and 1. * @param {number} angle - The Camera's new angle in radians. */ /** * This callback is invoked every frame for the duration of the effect. * * @name Phaser.Cameras.Scene2D.Effects.RotateTo#_onUpdate * @type {?CameraRotateCallback} * @private * @default null * @since 3.23.0 */ this._onUpdate; /** * On Complete callback scope. * * @name Phaser.Cameras.Scene2D.Effects.RotateTo#_onUpdateScope * @type {any} * @private * @since 3.23.0 */ this._onUpdateScope; /** * The direction of the rotation. * * @name Phaser.Cameras.Scene2D.Effects.RotateTo#clockwise * @type {boolean} * @since 3.23.0 */ this.clockwise = true; /** * The shortest direction to the target rotation. * * @name Phaser.Cameras.Scene2D.Effects.RotateTo#shortestPath * @type {boolean} * @since 3.23.0 */ this.shortestPath = false; }, /** * This effect will scroll the Camera so that the center of its viewport finishes at the given angle, * over the duration and with the ease specified. * * @method Phaser.Cameras.Scene2D.Effects.RotateTo#start * @fires Phaser.Cameras.Scene2D.Events#ROTATE_START * @fires Phaser.Cameras.Scene2D.Events#ROTATE_COMPLETE * @since 3.23.0 * * @param {number} radians - The destination angle in radians to rotate the Camera viewport to. If the angle is positive then the rotation is clockwise else anticlockwise * @param {boolean} [shortestPath=false] - If shortest path is set to true the camera will rotate in the quickest direction clockwise or anti-clockwise. * @param {number} [duration=1000] - The duration of the effect in milliseconds. * @param {(string|function)} [ease='Linear'] - The ease to use for the Rotate. Can be any of the Phaser Easing constants or a custom function. * @param {boolean} [force=false] - Force the rotation effect to start immediately, even if already running. * @param {CameraRotateCallback} [callback] - This callback will be invoked every frame for the duration of the effect. * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, * the current camera scroll x coordinate and the current camera scroll y coordinate. * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. * * @return {Phaser.Cameras.Scene2D.Camera} The Camera on which the effect was started. */ start: function (radians, shortestPath, duration, ease, force, callback, context) { if (duration === undefined) { duration = 1000; } if (ease === undefined) { ease = EaseMap.Linear; } if (force === undefined) { force = false; } if (callback === undefined) { callback = null; } if (context === undefined) { context = this.camera.scene; } if (shortestPath === undefined) { shortestPath = false; } this.shortestPath = shortestPath; var tmpDestination = radians; if (radians < 0) { tmpDestination = -1 * radians; this.clockwise = false; } else { this.clockwise = true; } var maxRad = (360 * Math.PI) / 180; tmpDestination = tmpDestination - (Math.floor(tmpDestination / maxRad) * maxRad); var cam = this.camera; if (!force && this.isRunning) { return cam; } this.isRunning = true; this.duration = duration; this.progress = 0; // Starting from this.source = cam.rotation; // Destination this.destination = tmpDestination; // Using this ease if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) { this.ease = EaseMap[ease]; } else if (typeof ease === 'function') { this.ease = ease; } this._elapsed = 0; this._onUpdate = callback; this._onUpdateScope = context; if (this.shortestPath) { // The shortest path is true so calculate the quickest direction var cwDist = 0; var acwDist = 0; if (this.destination > this.source) { cwDist = Math.abs(this.destination - this.source); } else { cwDist = (Math.abs(this.destination + maxRad) - this.source); } if (this.source > this.destination) { acwDist = Math.abs(this.source - this.destination); } else { acwDist = (Math.abs(this.source + maxRad) - this.destination); } if (cwDist < acwDist) { this.clockwise = true; } else if (cwDist > acwDist) { this.clockwise = false; } } this.camera.emit(Events.ROTATE_START, this.camera, this, duration, tmpDestination); return cam; }, /** * The main update loop for this effect. Called automatically by the Camera. * * @method Phaser.Cameras.Scene2D.Effects.RotateTo#update * @since 3.23.0 * * @param {number} 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.isRunning) { return; } this._elapsed += delta; var progress = Clamp(this._elapsed / this.duration, 0, 1); this.progress = progress; var cam = this.camera; if (this._elapsed < this.duration) { var v = this.ease(progress); this.current = cam.rotation; var distance = 0; var maxRad = (360 * Math.PI) / 180; var target = this.destination; var current = this.current; if (this.clockwise === false) { target = this.current; current = this.destination; } if (target >= current) { distance = Math.abs(target - current); } else { distance = (Math.abs(target + maxRad) - current); } var r = 0; if (this.clockwise) { r = (cam.rotation + (distance * v)); } else { r = (cam.rotation - (distance * v)); } cam.rotation = r; if (this._onUpdate) { this._onUpdate.call(this._onUpdateScope, cam, progress, r); } } else { cam.rotation = this.destination; if (this._onUpdate) { this._onUpdate.call(this._onUpdateScope, cam, progress, this.destination); } this.effectComplete(); } }, /** * Called internally when the effect completes. * * @method Phaser.Cameras.Scene2D.Effects.RotateTo#effectComplete * @since 3.23.0 */ effectComplete: function () { this._onUpdate = null; this._onUpdateScope = null; this.isRunning = false; this.camera.emit(Events.ROTATE_COMPLETE, this.camera, this); }, /** * Resets this camera effect. * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. * * @method Phaser.Cameras.Scene2D.Effects.RotateTo#reset * @since 3.23.0 */ reset: function () { this.isRunning = false; this._onUpdate = null; this._onUpdateScope = null; }, /** * Destroys this effect, releasing it from the Camera. * * @method Phaser.Cameras.Scene2D.Effects.RotateTo#destroy * @since 3.23.0 */ destroy: function () { this.reset(); this.camera = null; this.source = null; this.destination = null; } }); module.exports = RotateTo; /***/ }), /***/ 30330: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Clamp = __webpack_require__(45319); var Class = __webpack_require__(83419); var Events = __webpack_require__(19715); var Vector2 = __webpack_require__(26099); /** * @classdesc * A Camera Shake effect. * * This effect will shake the camera viewport by a random amount, bounded by the specified intensity, each frame. * * Only the camera viewport is moved. None of the objects it is displaying are impacted, i.e. their positions do * not change. * * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, * which is invoked each frame for the duration of the effect if required. * * @class Shake * @memberof Phaser.Cameras.Scene2D.Effects * @constructor * @since 3.5.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon. */ var Shake = new Class({ initialize: function Shake (camera) { /** * The Camera this effect belongs to. * * @name Phaser.Cameras.Scene2D.Effects.Shake#camera * @type {Phaser.Cameras.Scene2D.Camera} * @readonly * @since 3.5.0 */ this.camera = camera; /** * Is this effect actively running? * * @name Phaser.Cameras.Scene2D.Effects.Shake#isRunning * @type {boolean} * @readonly * @default false * @since 3.5.0 */ this.isRunning = false; /** * The duration of the effect, in milliseconds. * * @name Phaser.Cameras.Scene2D.Effects.Shake#duration * @type {number} * @readonly * @default 0 * @since 3.5.0 */ this.duration = 0; /** * The intensity of the effect. Use small float values. The default when the effect starts is 0.05. * This is a Vector2 object, allowing you to control the shake intensity independently across x and y. * You can modify this value while the effect is active to create more varied shake effects. * * @name Phaser.Cameras.Scene2D.Effects.Shake#intensity * @type {Phaser.Math.Vector2} * @since 3.5.0 */ this.intensity = new Vector2(); /** * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. * * @name Phaser.Cameras.Scene2D.Effects.Shake#progress * @type {number} * @since 3.5.0 */ this.progress = 0; /** * Effect elapsed timer. * * @name Phaser.Cameras.Scene2D.Effects.Shake#_elapsed * @type {number} * @private * @since 3.5.0 */ this._elapsed = 0; /** * How much to offset the camera by horizontally. * * @name Phaser.Cameras.Scene2D.Effects.Shake#_offsetX * @type {number} * @private * @default 0 * @since 3.0.0 */ this._offsetX = 0; /** * How much to offset the camera by vertically. * * @name Phaser.Cameras.Scene2D.Effects.Shake#_offsetY * @type {number} * @private * @default 0 * @since 3.0.0 */ this._offsetY = 0; /** * This callback is invoked every frame for the duration of the effect. * * @name Phaser.Cameras.Scene2D.Effects.Shake#_onUpdate * @type {?Phaser.Types.Cameras.Scene2D.CameraShakeCallback} * @private * @default null * @since 3.5.0 */ this._onUpdate; /** * On Complete callback scope. * * @name Phaser.Cameras.Scene2D.Effects.Shake#_onUpdateScope * @type {any} * @private * @since 3.5.0 */ this._onUpdateScope; }, /** * Shakes the Camera by the given intensity over the duration specified. * * @method Phaser.Cameras.Scene2D.Effects.Shake#start * @fires Phaser.Cameras.Scene2D.Events#SHAKE_START * @fires Phaser.Cameras.Scene2D.Events#SHAKE_COMPLETE * @since 3.5.0 * * @param {number} [duration=100] - The duration of the effect in milliseconds. * @param {(number|Phaser.Math.Vector2)} [intensity=0.05] - The intensity of the shake. * @param {boolean} [force=false] - Force the shake effect to start immediately, even if already running. * @param {Phaser.Types.Cameras.Scene2D.CameraShakeCallback} [callback] - This callback will be invoked every frame for the duration of the effect. * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. * * @return {Phaser.Cameras.Scene2D.Camera} The Camera on which the effect was started. */ start: function (duration, intensity, force, callback, context) { if (duration === undefined) { duration = 100; } if (intensity === undefined) { intensity = 0.05; } if (force === undefined) { force = false; } if (callback === undefined) { callback = null; } if (context === undefined) { context = this.camera.scene; } if (!force && this.isRunning) { return this.camera; } this.isRunning = true; this.duration = duration; this.progress = 0; if (typeof intensity === 'number') { this.intensity.set(intensity); } else { this.intensity.set(intensity.x, intensity.y); } this._elapsed = 0; this._offsetX = 0; this._offsetY = 0; this._onUpdate = callback; this._onUpdateScope = context; this.camera.emit(Events.SHAKE_START, this.camera, this, duration, intensity); return this.camera; }, /** * The pre-render step for this effect. Called automatically by the Camera. * * @method Phaser.Cameras.Scene2D.Effects.Shake#preRender * @since 3.5.0 */ preRender: function () { if (this.isRunning) { this.camera.matrix.translate(this._offsetX, this._offsetY); } }, /** * The main update loop for this effect. Called automatically by the Camera. * * @method Phaser.Cameras.Scene2D.Effects.Shake#update * @since 3.5.0 * * @param {number} 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.isRunning) { return; } this._elapsed += delta; this.progress = Clamp(this._elapsed / this.duration, 0, 1); if (this._onUpdate) { this._onUpdate.call(this._onUpdateScope, this.camera, this.progress); } if (this._elapsed < this.duration) { var intensity = this.intensity; var width = this.camera.width; var height = this.camera.height; var zoom = this.camera.zoom; this._offsetX = (Math.random() * intensity.x * width * 2 - intensity.x * width) * zoom; this._offsetY = (Math.random() * intensity.y * height * 2 - intensity.y * height) * zoom; if (this.camera.roundPixels) { this._offsetX = Math.round(this._offsetX); this._offsetY = Math.round(this._offsetY); } } else { this.effectComplete(); } }, /** * Called internally when the effect completes. * * @method Phaser.Cameras.Scene2D.Effects.Shake#effectComplete * @fires Phaser.Cameras.Scene2D.Events#SHAKE_COMPLETE * @since 3.5.0 */ effectComplete: function () { this._offsetX = 0; this._offsetY = 0; this._onUpdate = null; this._onUpdateScope = null; this.isRunning = false; this.camera.emit(Events.SHAKE_COMPLETE, this.camera, this); }, /** * Resets this camera effect. * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. * * @method Phaser.Cameras.Scene2D.Effects.Shake#reset * @since 3.5.0 */ reset: function () { this.isRunning = false; this._offsetX = 0; this._offsetY = 0; this._onUpdate = null; this._onUpdateScope = null; }, /** * Destroys this effect, releasing it from the Camera. * * @method Phaser.Cameras.Scene2D.Effects.Shake#destroy * @since 3.5.0 */ destroy: function () { this.reset(); this.camera = null; this.intensity = null; } }); module.exports = Shake; /***/ }), /***/ 45641: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Clamp = __webpack_require__(45319); var Class = __webpack_require__(83419); var EaseMap = __webpack_require__(62640); var Events = __webpack_require__(19715); /** * @classdesc * A Camera Zoom effect. * * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. * * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, * which is invoked each frame for the duration of the effect if required. * * @class Zoom * @memberof Phaser.Cameras.Scene2D.Effects * @constructor * @since 3.11.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon. */ var Zoom = new Class({ initialize: function Zoom (camera) { /** * The Camera this effect belongs to. * * @name Phaser.Cameras.Scene2D.Effects.Zoom#camera * @type {Phaser.Cameras.Scene2D.Camera} * @readonly * @since 3.11.0 */ this.camera = camera; /** * Is this effect actively running? * * @name Phaser.Cameras.Scene2D.Effects.Zoom#isRunning * @type {boolean} * @readonly * @default false * @since 3.11.0 */ this.isRunning = false; /** * The duration of the effect, in milliseconds. * * @name Phaser.Cameras.Scene2D.Effects.Zoom#duration * @type {number} * @readonly * @default 0 * @since 3.11.0 */ this.duration = 0; /** * The starting zoom value; * * @name Phaser.Cameras.Scene2D.Effects.Zoom#source * @type {number} * @since 3.11.0 */ this.source = 1; /** * The destination zoom value. * * @name Phaser.Cameras.Scene2D.Effects.Zoom#destination * @type {number} * @since 3.11.0 */ this.destination = 1; /** * The ease function to use during the zoom. * * @name Phaser.Cameras.Scene2D.Effects.Zoom#ease * @type {function} * @since 3.11.0 */ this.ease; /** * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. * * @name Phaser.Cameras.Scene2D.Effects.Zoom#progress * @type {number} * @since 3.11.0 */ this.progress = 0; /** * Effect elapsed timer. * * @name Phaser.Cameras.Scene2D.Effects.Zoom#_elapsed * @type {number} * @private * @since 3.11.0 */ this._elapsed = 0; /** * This callback is invoked every frame for the duration of the effect. * * @name Phaser.Cameras.Scene2D.Effects.Zoom#_onUpdate * @type {?Phaser.Types.Cameras.Scene2D.CameraZoomCallback} * @private * @default null * @since 3.11.0 */ this._onUpdate; /** * On Complete callback scope. * * @name Phaser.Cameras.Scene2D.Effects.Zoom#_onUpdateScope * @type {any} * @private * @since 3.11.0 */ this._onUpdateScope; }, /** * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. * * @method Phaser.Cameras.Scene2D.Effects.Zoom#start * @fires Phaser.Cameras.Scene2D.Events#ZOOM_START * @fires Phaser.Cameras.Scene2D.Events#ZOOM_COMPLETE * @since 3.11.0 * * @param {number} zoom - The target Camera zoom value. * @param {number} [duration=1000] - The duration of the effect in milliseconds. * @param {(string|function)} [ease='Linear'] - The ease to use for the Zoom. Can be any of the Phaser Easing constants or a custom function. * @param {boolean} [force=false] - Force the zoom effect to start immediately, even if already running. * @param {Phaser.Types.Cameras.Scene2D.CameraZoomCallback} [callback] - This callback will be invoked every frame for the duration of the effect. * It is sent three arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, * and the current camera zoom value. * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. * * @return {Phaser.Cameras.Scene2D.Camera} The Camera on which the effect was started. */ start: function (zoom, duration, ease, force, callback, context) { if (duration === undefined) { duration = 1000; } if (ease === undefined) { ease = EaseMap.Linear; } if (force === undefined) { force = false; } if (callback === undefined) { callback = null; } if (context === undefined) { context = this.camera.scene; } var cam = this.camera; if (!force && this.isRunning) { return cam; } this.isRunning = true; this.duration = duration; this.progress = 0; // Starting from this.source = cam.zoom; // Zooming to this.destination = zoom; // Using this ease if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) { this.ease = EaseMap[ease]; } else if (typeof ease === 'function') { this.ease = ease; } this._elapsed = 0; this._onUpdate = callback; this._onUpdateScope = context; this.camera.emit(Events.ZOOM_START, this.camera, this, duration, zoom); return cam; }, /** * The main update loop for this effect. Called automatically by the Camera. * * @method Phaser.Cameras.Scene2D.Effects.Zoom#update * @since 3.11.0 * * @param {number} 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.isRunning) { return; } this._elapsed += delta; this.progress = Clamp(this._elapsed / this.duration, 0, 1); if (this._elapsed < this.duration) { this.camera.zoom = this.source + ((this.destination - this.source) * this.ease(this.progress)); if (this._onUpdate) { this._onUpdate.call(this._onUpdateScope, this.camera, this.progress, this.camera.zoom); } } else { this.camera.zoom = this.destination; if (this._onUpdate) { this._onUpdate.call(this._onUpdateScope, this.camera, this.progress, this.destination); } this.effectComplete(); } }, /** * Called internally when the effect completes. * * @method Phaser.Cameras.Scene2D.Effects.Zoom#effectComplete * @fires Phaser.Cameras.Scene2D.Events#ZOOM_COMPLETE * @since 3.11.0 */ effectComplete: function () { this._onUpdate = null; this._onUpdateScope = null; this.isRunning = false; this.camera.emit(Events.ZOOM_COMPLETE, this.camera, this); }, /** * Resets this camera effect. * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. * * @method Phaser.Cameras.Scene2D.Effects.Zoom#reset * @since 3.11.0 */ reset: function () { this.isRunning = false; this._onUpdate = null; this._onUpdateScope = null; }, /** * Destroys this effect, releasing it from the Camera. * * @method Phaser.Cameras.Scene2D.Effects.Zoom#destroy * @since 3.11.0 */ destroy: function () { this.reset(); this.camera = null; } }); module.exports = Zoom; /***/ }), /***/ 20052: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Cameras.Scene2D.Effects */ module.exports = { Fade: __webpack_require__(5020), Flash: __webpack_require__(10662), Pan: __webpack_require__(20359), Shake: __webpack_require__(30330), RotateTo: __webpack_require__(34208), Zoom: __webpack_require__(45641) }; /***/ }), /***/ 16438: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Destroy Camera Event. * * This event is dispatched by a Camera instance when it is destroyed by the Camera Manager. * * Listen for it via either of the following: * * ```js * this.cameras.main.on('cameradestroy', () => {}); * ``` * * or use the constant, to avoid having to remember the correct event string: * * ```js * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.DESTROY, () => {}); * ``` * * @event Phaser.Cameras.Scene2D.Events#DESTROY * @type {string} * @since 3.0.0 * * @param {Phaser.Cameras.Scene2D.BaseCamera} camera - The camera that was destroyed. */ module.exports = 'cameradestroy'; /***/ }), /***/ 32726: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Camera Fade In Complete Event. * * This event is dispatched by a Camera instance when the Fade In Effect completes. * * Listen to it from a Camera instance using `Camera.on('camerafadeincomplete', listener)`. * * @event Phaser.Cameras.Scene2D.Events#FADE_IN_COMPLETE * @type {string} * @since 3.3.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. * @param {Phaser.Cameras.Scene2D.Effects.Fade} effect - A reference to the effect instance. */ module.exports = 'camerafadeincomplete'; /***/ }), /***/ 87807: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Camera Fade In Start Event. * * This event is dispatched by a Camera instance when the Fade In Effect starts. * * Listen to it from a Camera instance using `Camera.on('camerafadeinstart', listener)`. * * @event Phaser.Cameras.Scene2D.Events#FADE_IN_START * @type {string} * @since 3.3.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. * @param {Phaser.Cameras.Scene2D.Effects.Fade} effect - A reference to the effect instance. * @param {number} duration - The duration of the effect. * @param {number} red - The red color channel value. * @param {number} green - The green color channel value. * @param {number} blue - The blue color channel value. */ module.exports = 'camerafadeinstart'; /***/ }), /***/ 45917: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Camera Fade Out Complete Event. * * This event is dispatched by a Camera instance when the Fade Out Effect completes. * * Listen to it from a Camera instance using `Camera.on('camerafadeoutcomplete', listener)`. * * @event Phaser.Cameras.Scene2D.Events#FADE_OUT_COMPLETE * @type {string} * @since 3.3.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. * @param {Phaser.Cameras.Scene2D.Effects.Fade} effect - A reference to the effect instance. */ module.exports = 'camerafadeoutcomplete'; /***/ }), /***/ 95666: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Camera Fade Out Start Event. * * This event is dispatched by a Camera instance when the Fade Out Effect starts. * * Listen to it from a Camera instance using `Camera.on('camerafadeoutstart', listener)`. * * @event Phaser.Cameras.Scene2D.Events#FADE_OUT_START * @type {string} * @since 3.3.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. * @param {Phaser.Cameras.Scene2D.Effects.Fade} effect - A reference to the effect instance. * @param {number} duration - The duration of the effect. * @param {number} red - The red color channel value. * @param {number} green - The green color channel value. * @param {number} blue - The blue color channel value. */ module.exports = 'camerafadeoutstart'; /***/ }), /***/ 47056: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Camera Flash Complete Event. * * This event is dispatched by a Camera instance when the Flash Effect completes. * * Listen for it via either of the following: * * ```js * this.cameras.main.on('cameraflashcomplete', () => {}); * ``` * * or use the constant, to avoid having to remember the correct event string: * * ```js * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.FLASH_COMPLETE, () => {}); * ``` * * @event Phaser.Cameras.Scene2D.Events#FLASH_COMPLETE * @type {string} * @since 3.3.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. * @param {Phaser.Cameras.Scene2D.Effects.Flash} effect - A reference to the effect instance. */ module.exports = 'cameraflashcomplete'; /***/ }), /***/ 91261: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Camera Flash Start Event. * * This event is dispatched by a Camera instance when the Flash Effect starts. * * Listen for it via either of the following: * * ```js * this.cameras.main.on('cameraflashstart', () => {}); * ``` * * or use the constant, to avoid having to remember the correct event string: * * ```js * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.FLASH_START, () => {}); * ``` * * @event Phaser.Cameras.Scene2D.Events#FLASH_START * @type {string} * @since 3.3.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. * @param {Phaser.Cameras.Scene2D.Effects.Flash} effect - A reference to the effect instance. * @param {number} duration - The duration of the effect. * @param {number} red - The red color channel value. * @param {number} green - The green color channel value. * @param {number} blue - The blue color channel value. */ module.exports = 'cameraflashstart'; /***/ }), /***/ 45047: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Camera Follower Update Event. * * This event is dispatched by a Camera instance when it is following a * Game Object and the Camera position has been updated as a result of * that following. * * Listen to it from a Camera instance using: `camera.on('followupdate', listener)`. * * @event Phaser.Cameras.Scene2D.Events#FOLLOW_UPDATE * @type {string} * @since 3.50.0 * * @param {Phaser.Cameras.Scene2D.BaseCamera} camera - The camera that emitted the event. * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object the camera is following. */ module.exports = 'followupdate'; /***/ }), /***/ 81927: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Camera Pan Complete Event. * * This event is dispatched by a Camera instance when the Pan Effect completes. * * Listen for it via either of the following: * * ```js * this.cameras.main.on('camerapancomplete', () => {}); * ``` * * or use the constant, to avoid having to remember the correct event string: * * ```js * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.PAN_COMPLETE, () => {}); * ``` * * @event Phaser.Cameras.Scene2D.Events#PAN_COMPLETE * @type {string} * @since 3.3.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. * @param {Phaser.Cameras.Scene2D.Effects.Pan} effect - A reference to the effect instance. */ module.exports = 'camerapancomplete'; /***/ }), /***/ 74264: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Camera Pan Start Event. * * This event is dispatched by a Camera instance when the Pan Effect starts. * * Listen for it via either of the following: * * ```js * this.cameras.main.on('camerapanstart', () => {}); * ``` * * or use the constant, to avoid having to remember the correct event string: * * ```js * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.PAN_START, () => {}); * ``` * * @event Phaser.Cameras.Scene2D.Events#PAN_START * @type {string} * @since 3.3.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. * @param {Phaser.Cameras.Scene2D.Effects.Pan} effect - A reference to the effect instance. * @param {number} duration - The duration of the effect. * @param {number} x - The destination scroll x coordinate. * @param {number} y - The destination scroll y coordinate. */ module.exports = 'camerapanstart'; /***/ }), /***/ 54419: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Camera Post-Render Event. * * This event is dispatched by a Camera instance after is has finished rendering. * It is only dispatched if the Camera is rendering to a texture. * * Listen to it from a Camera instance using: `camera.on('postrender', listener)`. * * @event Phaser.Cameras.Scene2D.Events#POST_RENDER * @type {string} * @since 3.0.0 * * @param {Phaser.Cameras.Scene2D.BaseCamera} camera - The camera that has finished rendering to a texture. */ module.exports = 'postrender'; /***/ }), /***/ 79330: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Camera Pre-Render Event. * * This event is dispatched by a Camera instance when it is about to render. * It is only dispatched if the Camera is rendering to a texture. * * Listen to it from a Camera instance using: `camera.on('prerender', listener)`. * * @event Phaser.Cameras.Scene2D.Events#PRE_RENDER * @type {string} * @since 3.0.0 * * @param {Phaser.Cameras.Scene2D.BaseCamera} camera - The camera that is about to render to a texture. */ module.exports = 'prerender'; /***/ }), /***/ 93183: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Camera Rotate Complete Event. * * This event is dispatched by a Camera instance when the Rotate Effect completes. * * Listen for it via either of the following: * * ```js * this.cameras.main.on('camerarotatecomplete', () => {}); * ``` * * or use the constant, to avoid having to remember the correct event string: * * ```js * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.ROTATE_COMPLETE, () => {}); * ``` * * @event Phaser.Cameras.Scene2D.Events#ROTATE_COMPLETE * @type {string} * @since 3.23.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. * @param {Phaser.Cameras.Scene2D.Effects.RotateTo} effect - A reference to the effect instance. */ module.exports = 'camerarotatecomplete'; /***/ }), /***/ 80112: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Camera Rotate Start Event. * * This event is dispatched by a Camera instance when the Rotate Effect starts. * * Listen for it via either of the following: * * ```js * this.cameras.main.on('camerarotatestart', () => {}); * ``` * * or use the constant, to avoid having to remember the correct event string: * * ```js * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.ROTATE_START, () => {}); * ``` * * @event Phaser.Cameras.Scene2D.Events#ROTATE_START * @type {string} * @since 3.23.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. * @param {Phaser.Cameras.Scene2D.Effects.RotateTo} effect - A reference to the effect instance. * @param {number} duration - The duration of the effect. * @param {number} destination - The destination value. */ module.exports = 'camerarotatestart'; /***/ }), /***/ 62252: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Camera Shake Complete Event. * * This event is dispatched by a Camera instance when the Shake Effect completes. * * Listen for it via either of the following: * * ```js * this.cameras.main.on('camerashakecomplete', () => {}); * ``` * * or use the constant, to avoid having to remember the correct event string: * * ```js * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.SHAKE_COMPLETE, () => {}); * ``` * * @event Phaser.Cameras.Scene2D.Events#SHAKE_COMPLETE * @type {string} * @since 3.3.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. * @param {Phaser.Cameras.Scene2D.Effects.Shake} effect - A reference to the effect instance. */ module.exports = 'camerashakecomplete'; /***/ }), /***/ 86017: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Camera Shake Start Event. * * This event is dispatched by a Camera instance when the Shake Effect starts. * * Listen for it via either of the following: * * ```js * this.cameras.main.on('camerashakestart', () => {}); * ``` * * or use the constant, to avoid having to remember the correct event string: * * ```js * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.SHAKE_START, () => {}); * ``` * * @event Phaser.Cameras.Scene2D.Events#SHAKE_START * @type {string} * @since 3.3.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. * @param {Phaser.Cameras.Scene2D.Effects.Shake} effect - A reference to the effect instance. * @param {number} duration - The duration of the effect. * @param {number} intensity - The intensity of the effect. */ module.exports = 'camerashakestart'; /***/ }), /***/ 539: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Camera Zoom Complete Event. * * This event is dispatched by a Camera instance when the Zoom Effect completes. * * Listen for it via either of the following: * * ```js * this.cameras.main.on('camerazoomcomplete', () => {}); * ``` * * or use the constant, to avoid having to remember the correct event string: * * ```js * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.ZOOM_COMPLETE, () => {}); * ``` * * @event Phaser.Cameras.Scene2D.Events#ZOOM_COMPLETE * @type {string} * @since 3.3.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. * @param {Phaser.Cameras.Scene2D.Effects.Zoom} effect - A reference to the effect instance. */ module.exports = 'camerazoomcomplete'; /***/ }), /***/ 51892: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Camera Zoom Start Event. * * This event is dispatched by a Camera instance when the Zoom Effect starts. * * Listen for it via either of the following: * * ```js * this.cameras.main.on('camerazoomstart', () => {}); * ``` * * or use the constant, to avoid having to remember the correct event string: * * ```js * this.cameras.main.on(Phaser.Cameras.Scene2D.Events.ZOOM_START, () => {}); * ``` * * @event Phaser.Cameras.Scene2D.Events#ZOOM_START * @type {string} * @since 3.3.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. * @param {Phaser.Cameras.Scene2D.Effects.Zoom} effect - A reference to the effect instance. * @param {number} duration - The duration of the effect. * @param {number} zoom - The destination zoom value. */ module.exports = 'camerazoomstart'; /***/ }), /***/ 19715: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Cameras.Scene2D.Events */ module.exports = { DESTROY: __webpack_require__(16438), FADE_IN_COMPLETE: __webpack_require__(32726), FADE_IN_START: __webpack_require__(87807), FADE_OUT_COMPLETE: __webpack_require__(45917), FADE_OUT_START: __webpack_require__(95666), FLASH_COMPLETE: __webpack_require__(47056), FLASH_START: __webpack_require__(91261), FOLLOW_UPDATE: __webpack_require__(45047), PAN_COMPLETE: __webpack_require__(81927), PAN_START: __webpack_require__(74264), POST_RENDER: __webpack_require__(54419), PRE_RENDER: __webpack_require__(79330), ROTATE_COMPLETE: __webpack_require__(93183), ROTATE_START: __webpack_require__(80112), SHAKE_COMPLETE: __webpack_require__(62252), SHAKE_START: __webpack_require__(86017), ZOOM_COMPLETE: __webpack_require__(539), ZOOM_START: __webpack_require__(51892) }; /***/ }), /***/ 87969: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Cameras.Scene2D */ module.exports = { Camera: __webpack_require__(38058), BaseCamera: __webpack_require__(71911), CameraManager: __webpack_require__(32743), Effects: __webpack_require__(20052), Events: __webpack_require__(19715) }; /***/ }), /***/ 63091: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Class = __webpack_require__(83419); var GetValue = __webpack_require__(35154); /** * @classdesc * A Fixed Key Camera Control. * * This allows you to control the movement and zoom of a camera using the defined keys. * * ```javascript * var camControl = new FixedKeyControl({ * camera: this.cameras.main, * left: cursors.left, * right: cursors.right, * speed: float OR { x: 0, y: 0 } * }); * ``` * * Movement is precise and has no 'smoothing' applied to it. * * You must call the `update` method of this controller every frame. * * @class FixedKeyControl * @memberof Phaser.Cameras.Controls * @constructor * @since 3.0.0 * * @param {Phaser.Types.Cameras.Controls.FixedKeyControlConfig} config - The Fixed Key Control configuration object. */ 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 {number} * @default 0.01 * @since 3.0.0 */ this.zoomSpeed = GetValue(config, 'zoomSpeed', 0.01); /** * The smallest zoom value the camera will reach when zoomed out. * * @name Phaser.Cameras.Controls.FixedKeyControl#minZoom * @type {number} * @default 0.001 * @since 3.53.0 */ this.minZoom = GetValue(config, 'minZoom', 0.001); /** * The largest zoom value the camera will reach when zoomed in. * * @name Phaser.Cameras.Controls.FixedKeyControl#maxZoom * @type {number} * @default 1000 * @since 3.53.0 */ this.maxZoom = GetValue(config, 'maxZoom', 1000); /** * The horizontal speed the camera will move. * * @name Phaser.Cameras.Controls.FixedKeyControl#speedX * @type {number} * @default 0 * @since 3.0.0 */ this.speedX = 0; /** * The vertical speed the camera will move. * * @name Phaser.Cameras.Controls.FixedKeyControl#speedY * @type {number} * @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); } /** * Internal property to track the current zoom level. * * @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 {this} 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 {this} 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 {this} This Key Control instance. */ setCamera: function (camera) { this.camera = camera; return this; }, /** * Applies the results of pressing the control keys to the Camera. * * You must call this every step, it is not called automatically. * * @method Phaser.Cameras.Controls.FixedKeyControl#update * @since 3.0.0 * * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ 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 < this.minZoom) { cam.zoom = this.minZoom; } } else if (this.zoomOut && this.zoomOut.isDown) { cam.zoom += this.zoomSpeed; if (cam.zoom > this.maxZoom) { cam.zoom = this.maxZoom; } } }, /** * 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; /***/ }), /***/ 58818: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Class = __webpack_require__(83419); var GetValue = __webpack_require__(35154); /** * @classdesc * A Smoothed Key Camera Control. * * This allows you to control the movement and zoom of a camera using the defined keys. * Unlike the Fixed Camera Control you can also provide physics values for acceleration, drag and maxSpeed for smoothing effects. * * ```javascript * 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 * }; * ``` * * You must call the `update` method of this controller every frame. * * @class SmoothedKeyControl * @memberof Phaser.Cameras.Controls * @constructor * @since 3.0.0 * * @param {Phaser.Types.Cameras.Controls.SmoothedKeyControlConfig} config - The Smoothed Key Control configuration object. */ 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 {number} * @default 0.01 * @since 3.0.0 */ this.zoomSpeed = GetValue(config, 'zoomSpeed', 0.01); /** * The smallest zoom value the camera will reach when zoomed out. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#minZoom * @type {number} * @default 0.001 * @since 3.53.0 */ this.minZoom = GetValue(config, 'minZoom', 0.001); /** * The largest zoom value the camera will reach when zoomed in. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxZoom * @type {number} * @default 1000 * @since 3.53.0 */ this.maxZoom = GetValue(config, 'maxZoom', 1000); /** * The horizontal acceleration the camera will move. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelX * @type {number} * @default 0 * @since 3.0.0 */ this.accelX = 0; /** * The vertical acceleration the camera will move. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelY * @type {number} * @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 {number} * @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 {number} * @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 {number} * @default 0 * @since 3.0.0 */ this.maxSpeedX = 0; /** * The maximum vertical speed the camera will move. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedY * @type {number} * @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); } /** * Internal property to track the speed of the control. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#_speedX * @type {number} * @private * @default 0 * @since 3.0.0 */ this._speedX = 0; /** * Internal property to track the speed of the control. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#_speedY * @type {number} * @private * @default 0 * @since 3.0.0 */ this._speedY = 0; /** * Internal property to track the zoom of the control. * * @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 {this} 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 {this} 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 {this} This Key Control instance. */ setCamera: function (camera) { this.camera = camera; return this; }, /** * Applies the results of pressing the control keys to the Camera. * * You must call this every step, it is not called automatically. * * @method Phaser.Cameras.Controls.SmoothedKeyControl#update * @since 3.0.0 * * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ 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 < this.minZoom) { cam.zoom = this.minZoom; } else if (cam.zoom > this.maxZoom) { cam.zoom = this.maxZoom; } } }, /** * 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; /***/ }), /***/ 38865: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Cameras.Controls */ module.exports = { FixedKeyControl: __webpack_require__(63091), SmoothedKeyControl: __webpack_require__(58818) }; /***/ }), /***/ 26638: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Cameras */ /** * @namespace Phaser.Types.Cameras */ module.exports = { Controls: __webpack_require__(38865), Scene2D: __webpack_require__(87969) }; /***/ }), /***/ 8054: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * Global constants. * * @ignore */ var CONST = { /** * Phaser Release Version * * @name Phaser.VERSION * @const * @type {string} * @since 3.0.0 */ VERSION: '3.87', /** * Phaser Release Version as displayed in the console.log header URL. * * @name Phaser.LOG_VERSION * @const * @type {string} * @since 3.87.0 */ LOG_VERSION: 'v387', BlendModes: __webpack_require__(10312), ScaleModes: __webpack_require__(29795), /** * This setting will auto-detect if the browser is capable of suppporting WebGL. * If it is, it will use the WebGL Renderer. If not, it will fall back to the Canvas Renderer. * * @name Phaser.AUTO * @const * @type {number} * @since 3.0.0 */ AUTO: 0, /** * Forces Phaser to only use the Canvas Renderer, regardless if the browser supports * WebGL or not. * * @name Phaser.CANVAS * @const * @type {number} * @since 3.0.0 */ CANVAS: 1, /** * Forces Phaser to use the WebGL Renderer. If the browser does not support it, there is * no fallback to Canvas with this setting, so you should trap it and display a suitable * message to the user. * * @name Phaser.WEBGL * @const * @type {number} * @since 3.0.0 */ WEBGL: 2, /** * A Headless Renderer doesn't create either a Canvas or WebGL Renderer. However, it still * absolutely relies on the DOM being present and available. This mode is meant for unit testing, * not for running Phaser on the server, which is something you really shouldn't do. * * @name Phaser.HEADLESS * @const * @type {number} * @since 3.0.0 */ HEADLESS: 3, /** * In Phaser the value -1 means 'forever' in lots of cases, this const allows you to use it instead * to help you remember what the value is doing in your code. * * @name Phaser.FOREVER * @const * @type {number} * @since 3.0.0 */ FOREVER: -1, /** * Direction constant. * * @name Phaser.NONE * @const * @type {number} * @since 3.0.0 */ NONE: 4, /** * Direction constant. * * @name Phaser.UP * @const * @type {number} * @since 3.0.0 */ UP: 5, /** * Direction constant. * * @name Phaser.DOWN * @const * @type {number} * @since 3.0.0 */ DOWN: 6, /** * Direction constant. * * @name Phaser.LEFT * @const * @type {number} * @since 3.0.0 */ LEFT: 7, /** * Direction constant. * * @name Phaser.RIGHT * @const * @type {number} * @since 3.0.0 */ RIGHT: 8 }; module.exports = CONST; /***/ }), /***/ 69547: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Class = __webpack_require__(83419); var CONST = __webpack_require__(8054); var DefaultPlugins = __webpack_require__(42363); var Device = __webpack_require__(82264); var GetFastValue = __webpack_require__(95540); var GetValue = __webpack_require__(35154); var IsPlainObject = __webpack_require__(41212); var NOOP = __webpack_require__(29747); var PhaserMath = __webpack_require__(75508); var PIPELINE_CONST = __webpack_require__(36060); var ValueToColor = __webpack_require__(80333); /** * @classdesc * The active game configuration settings, parsed from a {@link Phaser.Types.Core.GameConfig} object. * * @class Config * @memberof Phaser.Core * @constructor * @since 3.0.0 * * @param {Phaser.Types.Core.GameConfig} [GameConfig] - The configuration object for your Phaser Game instance. * * @see Phaser.Game#config */ var Config = new Class({ initialize: function Config (config) { if (config === undefined) { config = {}; } var defaultBannerColor = [ '#ff0000', '#ffff00', '#00ff00', '#00ffff', '#000000' ]; var defaultBannerTextColor = '#ffffff'; // Scale Manager - Anything set in here over-rides anything set in the core game config var scaleConfig = GetValue(config, 'scale', null); /** * @const {(number|string)} Phaser.Core.Config#width - The width of the underlying canvas, in pixels. */ this.width = GetValue(scaleConfig, 'width', 1024, config); /** * @const {(number|string)} Phaser.Core.Config#height - The height of the underlying canvas, in pixels. */ this.height = GetValue(scaleConfig, 'height', 768, config); /** * @const {(Phaser.Scale.ZoomType|number)} Phaser.Core.Config#zoom - The zoom factor, as used by the Scale Manager. */ this.zoom = GetValue(scaleConfig, 'zoom', 1, config); /** * @const {?*} Phaser.Core.Config#parent - A parent DOM element into which the canvas created by the renderer will be injected. */ this.parent = GetValue(scaleConfig, 'parent', undefined, config); /** * @const {Phaser.Scale.ScaleModeType} Phaser.Core.Config#scaleMode - The scale mode as used by the Scale Manager. The default is zero, which is no scaling. */ this.scaleMode = GetValue(scaleConfig, (scaleConfig) ? 'mode' : 'scaleMode', 0, config); /** * @const {boolean} Phaser.Core.Config#expandParent - Is the Scale Manager allowed to adjust the CSS height property of the parent to be 100%? */ this.expandParent = GetValue(scaleConfig, 'expandParent', true, config); /** * @const {boolean} Phaser.Core.Config#autoRound - Automatically round the display and style sizes of the canvas. This can help with performance in lower-powered devices. */ this.autoRound = GetValue(scaleConfig, 'autoRound', false, config); /** * @const {Phaser.Scale.CenterType} Phaser.Core.Config#autoCenter - Automatically center the canvas within the parent? */ this.autoCenter = GetValue(scaleConfig, 'autoCenter', 0, config); /** * @const {number} Phaser.Core.Config#resizeInterval - How many ms should elapse before checking if the browser size has changed? */ this.resizeInterval = GetValue(scaleConfig, 'resizeInterval', 500, config); /** * @const {?(HTMLElement|string)} Phaser.Core.Config#fullscreenTarget - The DOM element that will be sent into full screen mode, or its `id`. If undefined Phaser will create its own div and insert the canvas into it when entering fullscreen mode. */ this.fullscreenTarget = GetValue(scaleConfig, 'fullscreenTarget', null, config); /** * @const {number} Phaser.Core.Config#minWidth - The minimum width, in pixels, the canvas will scale down to. A value of zero means no minimum. */ this.minWidth = GetValue(scaleConfig, 'min.width', 0, config); /** * @const {number} Phaser.Core.Config#maxWidth - The maximum width, in pixels, the canvas will scale up to. A value of zero means no maximum. */ this.maxWidth = GetValue(scaleConfig, 'max.width', 0, config); /** * @const {number} Phaser.Core.Config#minHeight - The minimum height, in pixels, the canvas will scale down to. A value of zero means no minimum. */ this.minHeight = GetValue(scaleConfig, 'min.height', 0, config); /** * @const {number} Phaser.Core.Config#maxHeight - The maximum height, in pixels, the canvas will scale up to. A value of zero means no maximum. */ this.maxHeight = GetValue(scaleConfig, 'max.height', 0, config); /** * @const {number} Phaser.Core.Config#snapWidth - The horizontal amount to snap the canvas by when the Scale Manager is resizing. A value of zero means no snapping. */ this.snapWidth = GetValue(scaleConfig, 'snap.width', 0, config); /** * @const {number} Phaser.Core.Config#snapHeight - The vertical amount to snap the canvas by when the Scale Manager is resizing. A value of zero means no snapping. */ this.snapHeight = GetValue(scaleConfig, 'snap.height', 0, config); /** * @const {number} Phaser.Core.Config#renderType - Force Phaser to use a specific renderer. Can be `CONST.CANVAS`, `CONST.WEBGL`, `CONST.HEADLESS` or `CONST.AUTO` (default) */ this.renderType = GetValue(config, 'type', CONST.AUTO); /** * @const {?HTMLCanvasElement} Phaser.Core.Config#canvas - Force Phaser to use your own Canvas element instead of creating one. */ this.canvas = GetValue(config, 'canvas', null); /** * @const {?(CanvasRenderingContext2D|WebGLRenderingContext)} Phaser.Core.Config#context - Force Phaser to use your own Canvas context instead of creating one. */ this.context = GetValue(config, 'context', null); /** * @const {?string} Phaser.Core.Config#canvasStyle - Optional CSS attributes to be set on the canvas object created by the renderer. */ this.canvasStyle = GetValue(config, 'canvasStyle', null); /** * @const {boolean} Phaser.Core.Config#customEnvironment - Is Phaser running under a custom (non-native web) environment? If so, set this to `true` to skip internal Feature detection. If `true` the `renderType` cannot be left as `AUTO`. */ this.customEnvironment = GetValue(config, 'customEnvironment', false); /** * @const {?object} Phaser.Core.Config#sceneConfig - The default Scene configuration object. */ this.sceneConfig = GetValue(config, 'scene', null); /** * @const {string[]} Phaser.Core.Config#seed - A seed which the Random Data Generator will use. If not given, a dynamic seed based on the time is used. */ this.seed = GetValue(config, 'seed', [ (Date.now() * Math.random()).toString() ]); PhaserMath.RND = new PhaserMath.RandomDataGenerator(this.seed); /** * @const {string} Phaser.Core.Config#gameTitle - The title of the game. */ this.gameTitle = GetValue(config, 'title', ''); /** * @const {string} Phaser.Core.Config#gameURL - The URL of the game. */ this.gameURL = GetValue(config, 'url', 'https://phaser.io/' + CONST.LOG_VERSION); /** * @const {string} Phaser.Core.Config#gameVersion - The version of the game. */ this.gameVersion = GetValue(config, 'version', ''); /** * @const {boolean} Phaser.Core.Config#autoFocus - If `true` the window will automatically be given focus immediately and on any future mousedown event. */ this.autoFocus = GetValue(config, 'autoFocus', true); /** * @const {(number|boolean)} Phaser.Core.Config#stableSort - `false` or `0` = Use the built-in StableSort (needed for older browsers), `true` or `1` = Rely on ES2019 Array.sort being stable (modern browsers only), or `-1` = Try and determine this automatically based on browser inspection (not guaranteed to work, errs on side of caution). */ this.stableSort = GetValue(config, 'stableSort', -1); if (this.stableSort === -1) { this.stableSort = (Device.browser.es2019) ? 1 : 0; } Device.features.stableSort = this.stableSort; // DOM Element Container /** * @const {?boolean} Phaser.Core.Config#domCreateContainer - Should the game create a div element to act as a DOM Container? Only enable if you're using DOM Element objects. You must provide a parent object if you use this feature. */ this.domCreateContainer = GetValue(config, 'dom.createContainer', false); /** * @const {?string} Phaser.Core.Config#domPointerEvents - The default `pointerEvents` attribute set on the DOM Container. */ this.domPointerEvents = GetValue(config, 'dom.pointerEvents', 'none'); // Input /** * @const {boolean} Phaser.Core.Config#inputKeyboard - Enable the Keyboard Plugin. This can be disabled in games that don't need keyboard input. */ this.inputKeyboard = GetValue(config, 'input.keyboard', true); /** * @const {*} Phaser.Core.Config#inputKeyboardEventTarget - The DOM Target to listen for keyboard events on. Defaults to `window` if not specified. */ this.inputKeyboardEventTarget = GetValue(config, 'input.keyboard.target', window); /** * @const {?number[]} Phaser.Core.Config#inputKeyboardCapture - `preventDefault` will be called on every non-modified key which has a key code in this array. By default, it is empty. */ this.inputKeyboardCapture = GetValue(config, 'input.keyboard.capture', []); /** * @const {(boolean|object)} Phaser.Core.Config#inputMouse - Enable the Mouse Plugin. This can be disabled in games that don't need mouse input. */ this.inputMouse = GetValue(config, 'input.mouse', true); /** * @const {?*} Phaser.Core.Config#inputMouseEventTarget - The DOM Target to listen for mouse events on. Defaults to the game canvas if not specified. */ this.inputMouseEventTarget = GetValue(config, 'input.mouse.target', null); /** * @const {boolean} Phaser.Core.Config#inputMousePreventDefaultDown - Should `mousedown` DOM events have `preventDefault` called on them? */ this.inputMousePreventDefaultDown = GetValue(config, 'input.mouse.preventDefaultDown', true); /** * @const {boolean} Phaser.Core.Config#inputMousePreventDefaultUp - Should `mouseup` DOM events have `preventDefault` called on them? */ this.inputMousePreventDefaultUp = GetValue(config, 'input.mouse.preventDefaultUp', true); /** * @const {boolean} Phaser.Core.Config#inputMousePreventDefaultMove - Should `mousemove` DOM events have `preventDefault` called on them? */ this.inputMousePreventDefaultMove = GetValue(config, 'input.mouse.preventDefaultMove', true); /** * @const {boolean} Phaser.Core.Config#inputMousePreventDefaultWheel - Should `wheel` DOM events have `preventDefault` called on them? */ this.inputMousePreventDefaultWheel = GetValue(config, 'input.mouse.preventDefaultWheel', true); /** * @const {boolean} Phaser.Core.Config#inputTouch - Enable the Touch Plugin. This can be disabled in games that don't need touch input. */ this.inputTouch = GetValue(config, 'input.touch', Device.input.touch); /** * @const {?*} Phaser.Core.Config#inputTouchEventTarget - The DOM Target to listen for touch events on. Defaults to the game canvas if not specified. */ this.inputTouchEventTarget = GetValue(config, 'input.touch.target', null); /** * @const {boolean} Phaser.Core.Config#inputTouchCapture - Should touch events be captured? I.e. have prevent default called on them. */ this.inputTouchCapture = GetValue(config, 'input.touch.capture', true); /** * @const {number} Phaser.Core.Config#inputActivePointers - The number of Pointer objects created by default. In a mouse-only, or non-multi touch game, you can leave this as 1. */ this.inputActivePointers = GetValue(config, 'input.activePointers', 1); /** * @const {number} Phaser.Core.Config#inputSmoothFactor - The smoothing factor to apply during Pointer movement. See {@link Phaser.Input.Pointer#smoothFactor}. */ this.inputSmoothFactor = GetValue(config, 'input.smoothFactor', 0); /** * @const {boolean} Phaser.Core.Config#inputWindowEvents - Should Phaser listen for input events on the Window? If you disable this, events like 'POINTER_UP_OUTSIDE' will no longer fire. */ this.inputWindowEvents = GetValue(config, 'input.windowEvents', true); /** * @const {boolean} Phaser.Core.Config#inputGamepad - Enable the Gamepad Plugin. This can be disabled in games that don't need gamepad input. */ this.inputGamepad = GetValue(config, 'input.gamepad', false); /** * @const {*} Phaser.Core.Config#inputGamepadEventTarget - The DOM Target to listen for gamepad events on. Defaults to `window` if not specified. */ this.inputGamepadEventTarget = GetValue(config, 'input.gamepad.target', window); /** * @const {boolean} Phaser.Core.Config#disableContextMenu - Set to `true` to disable the right-click context menu. */ this.disableContextMenu = GetValue(config, 'disableContextMenu', false); /** * @const {Phaser.Types.Core.AudioConfig} Phaser.Core.Config#audio - The Audio Configuration object. */ this.audio = GetValue(config, 'audio', {}); // If you do: { banner: false } it won't display any banner at all /** * @const {boolean} Phaser.Core.Config#hideBanner - Don't write the banner line to the console.log. See `Phaser.Types.Core.BannerConfig` for details of this object. */ this.hideBanner = (GetValue(config, 'banner', null) === false); /** * @const {boolean} Phaser.Core.Config#hidePhaser - Omit Phaser's name and version from the banner. */ this.hidePhaser = GetValue(config, 'banner.hidePhaser', false); /** * @const {string} Phaser.Core.Config#bannerTextColor - The color of the banner text. */ this.bannerTextColor = GetValue(config, 'banner.text', defaultBannerTextColor); /** * @const {string[]} Phaser.Core.Config#bannerBackgroundColor - The background colors of the banner. */ this.bannerBackgroundColor = GetValue(config, 'banner.background', defaultBannerColor); if (this.gameTitle === '' && this.hidePhaser) { this.hideBanner = true; } /** * @const {Phaser.Types.Core.FPSConfig} Phaser.Core.Config#fps - The Frame Rate Configuration object, as parsed by the Timestep class. */ this.fps = GetValue(config, 'fps', null); /** * @const {boolean} Phaser.Core.Config#disablePreFX - Disables the automatic creation of the Pre FX Pipelines. If disabled, you cannot use the built-in Pre FX on Game Objects. */ this.disablePreFX = GetValue(config, 'disablePreFX', false); /** * @const {boolean} Phaser.Core.Config#disablePostFX - Disables the automatic creation of the Post FX Pipelines. If disabled, you cannot use the built-in Post FX on Game Objects. */ this.disablePostFX = GetValue(config, 'disablePostFX', false); // Render Settings - Anything set in here over-rides anything set in the core game config var renderConfig = GetValue(config, 'render', null); /** * @const {Phaser.Types.Core.PipelineConfig} Phaser.Core.Config#pipeline - An object mapping WebGL names to WebGLPipeline classes. These should be class constructors, not instances. */ this.pipeline = GetValue(renderConfig, 'pipeline', null, config); /** * @const {boolean} Phaser.Core.Config#autoMobilePipeline - Automatically enable the Mobile Pipeline if iOS or Android detected? */ this.autoMobilePipeline = GetValue(renderConfig, 'autoMobilePipeline', true, config); /** * @const {string} Phaser.Core.Config#defaultPipeline - The WebGL Pipeline that Game Objects will use by default. Set to 'MultiPipeline' as standard. See also 'autoMobilePipeline'. */ this.defaultPipeline = GetValue(renderConfig, 'defaultPipeline', PIPELINE_CONST.MULTI_PIPELINE, config); /** * @const {boolean} Phaser.Core.Config#antialias - When set to `true`, WebGL uses linear interpolation to draw scaled or rotated textures, giving a smooth appearance. When set to `false`, WebGL uses nearest-neighbor interpolation, giving a crisper appearance. `false` also disables antialiasing of the game canvas itself, if the browser supports it, when the game canvas is scaled. */ this.antialias = GetValue(renderConfig, 'antialias', true, config); /** * @const {boolean} Phaser.Core.Config#antialiasGL - Sets the `antialias` property when the WebGL context is created. Setting this value does not impact any subsequent textures that are created, or the canvas style attributes. */ this.antialiasGL = GetValue(renderConfig, 'antialiasGL', true, config); /** * @const {string} Phaser.Core.Config#mipmapFilter - Sets the mipmap magFilter to be used when creating WebGL textures. Don't set unless you wish to create mipmaps. Set to one of the following: 'NEAREST', 'LINEAR', 'NEAREST_MIPMAP_NEAREST', 'LINEAR_MIPMAP_NEAREST', 'NEAREST_MIPMAP_LINEAR' or 'LINEAR_MIPMAP_LINEAR'. */ this.mipmapFilter = GetValue(renderConfig, 'mipmapFilter', '', config); /** * @const {boolean} Phaser.Core.Config#desynchronized - When set to `true` it will create a desynchronized context for both 2D and WebGL. See https://developers.google.com/web/updates/2019/05/desynchronized for details. */ this.desynchronized = GetValue(renderConfig, 'desynchronized', false, config); /** * @const {boolean} Phaser.Core.Config#roundPixels - Draw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property. */ this.roundPixels = GetValue(renderConfig, 'roundPixels', false, config); /** * @const {boolean} Phaser.Core.Config#pixelArt - Prevent pixel art from becoming blurred when scaled. It will remain crisp (tells the WebGL renderer to automatically create textures using a linear filter mode). */ this.pixelArt = GetValue(renderConfig, 'pixelArt', this.zoom !== 1, config); if (this.pixelArt) { this.antialias = false; this.antialiasGL = false; this.roundPixels = true; } /** * @const {boolean} Phaser.Core.Config#transparent - Whether the game canvas will have a transparent background. */ this.transparent = GetValue(renderConfig, 'transparent', false, config); /** * @const {boolean} Phaser.Core.Config#clearBeforeRender - Whether the game canvas will be cleared between each rendering frame. You can disable this if you have a full-screen background image or game object. */ this.clearBeforeRender = GetValue(renderConfig, 'clearBeforeRender', true, config); /** * @const {boolean} Phaser.Core.Config#preserveDrawingBuffer - If the value is true the WebGL buffers will not be cleared and will preserve their values until cleared or overwritten by the author. */ this.preserveDrawingBuffer = GetValue(renderConfig, 'preserveDrawingBuffer', false, config); /** * @const {boolean} Phaser.Core.Config#premultipliedAlpha - In WebGL mode, sets the drawing buffer to contain colors with pre-multiplied alpha. */ this.premultipliedAlpha = GetValue(renderConfig, 'premultipliedAlpha', true, config); /** * @const {boolean} Phaser.Core.Config#failIfMajorPerformanceCaveat - Let the browser abort creating a WebGL context if it judges performance would be unacceptable. */ this.failIfMajorPerformanceCaveat = GetValue(renderConfig, 'failIfMajorPerformanceCaveat', false, config); /** * @const {string} Phaser.Core.Config#powerPreference - "high-performance", "low-power" or "default". A hint to the browser on how much device power the game might use. */ this.powerPreference = GetValue(renderConfig, 'powerPreference', 'default', config); /** * @const {number} Phaser.Core.Config#batchSize - The default WebGL Batch size. Represents the number of _quads_ that can be added to a single batch. */ this.batchSize = GetValue(renderConfig, 'batchSize', 4096, config); /** * @const {number} Phaser.Core.Config#maxTextures - When in WebGL mode, this sets the maximum number of GPU Textures to use. The default, -1, will use all available units. The WebGL1 spec says all browsers should provide a minimum of 8. */ this.maxTextures = GetValue(renderConfig, 'maxTextures', -1, config); /** * @const {number} Phaser.Core.Config#maxLights - The maximum number of lights allowed to be visible within range of a single Camera in the LightManager. */ this.maxLights = GetValue(renderConfig, 'maxLights', 10, config); var bgc = GetValue(config, 'backgroundColor', 0); /** * @const {Phaser.Display.Color} Phaser.Core.Config#backgroundColor - The background color of the game canvas. The default is black. This value is ignored if `transparent` is set to `true`. */ this.backgroundColor = ValueToColor(bgc); if (this.transparent) { this.backgroundColor = ValueToColor(0x000000); this.backgroundColor.alpha = 0; } /** * @const {Phaser.Types.Core.BootCallback} Phaser.Core.Config#preBoot - Called before Phaser boots. Useful for initializing anything not related to Phaser that Phaser may require while booting. */ this.preBoot = GetValue(config, 'callbacks.preBoot', NOOP); /** * @const {Phaser.Types.Core.BootCallback} Phaser.Core.Config#postBoot - A function to run at the end of the boot sequence. At this point, all the game systems have started and plugins have been loaded. */ this.postBoot = GetValue(config, 'callbacks.postBoot', NOOP); /** * @const {Phaser.Types.Core.PhysicsConfig} Phaser.Core.Config#physics - The Physics Configuration object. */ this.physics = GetValue(config, 'physics', {}); /** * @const {(boolean|string)} Phaser.Core.Config#defaultPhysicsSystem - The default physics system. It will be started for each scene. Either 'arcade', 'impact' or 'matter'. */ this.defaultPhysicsSystem = GetValue(this.physics, 'default', false); /** * @const {string} Phaser.Core.Config#loaderBaseURL - A URL used to resolve paths given to the loader. Example: 'http://labs.phaser.io/assets/'. */ this.loaderBaseURL = GetValue(config, 'loader.baseURL', ''); /** * @const {string} Phaser.Core.Config#loaderPath - A URL path used to resolve relative paths given to the loader. Example: 'images/sprites/'. */ this.loaderPath = GetValue(config, 'loader.path', ''); /** * @const {number} Phaser.Core.Config#loaderMaxParallelDownloads - Maximum parallel downloads allowed for resources (Default to 32). */ this.loaderMaxParallelDownloads = GetValue(config, 'loader.maxParallelDownloads', (Device.os.android) ? 6 : 32); /** * @const {(string|undefined)} Phaser.Core.Config#loaderCrossOrigin - 'anonymous', 'use-credentials', or `undefined`. If you're not making cross-origin requests, leave this as `undefined`. See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes}. */ this.loaderCrossOrigin = GetValue(config, 'loader.crossOrigin', undefined); /** * @const {string} Phaser.Core.Config#loaderResponseType - The response type of the XHR request, e.g. `blob`, `text`, etc. */ this.loaderResponseType = GetValue(config, 'loader.responseType', ''); /** * @const {boolean} Phaser.Core.Config#loaderAsync - Should the XHR request use async or not? */ this.loaderAsync = GetValue(config, 'loader.async', true); /** * @const {string} Phaser.Core.Config#loaderUser - Optional username for all XHR requests. */ this.loaderUser = GetValue(config, 'loader.user', ''); /** * @const {string} Phaser.Core.Config#loaderPassword - Optional password for all XHR requests. */ this.loaderPassword = GetValue(config, 'loader.password', ''); /** * @const {number} Phaser.Core.Config#loaderTimeout - Optional XHR timeout value, in ms. */ this.loaderTimeout = GetValue(config, 'loader.timeout', 0); /** * @const {number} Phaser.Core.Config#loaderMaxRetries - The number of times to retry a file load if it fails. */ this.loaderMaxRetries = GetValue(config, 'loader.maxRetries', 2); /** * @const {boolean} Phaser.Core.Config#loaderWithCredentials - Optional XHR withCredentials value. */ this.loaderWithCredentials = GetValue(config, 'loader.withCredentials', false); /** * @const {string} Phaser.Core.Config#loaderImageLoadType - Optional load type for image, `XHR` is default, or `HTMLImageElement` for a lightweight way. */ this.loaderImageLoadType = GetValue(config, 'loader.imageLoadType', 'XHR'); // On iOS, Capacitor often runs on a capacitor:// protocol, meaning local files are served from capacitor:// rather than file:// // See: https://github.com/photonstorm/phaser/issues/5685 /** * @const {string[]} Phaser.Core.Config#loaderLocalScheme - An array of schemes that the Loader considers as being 'local' files. Defaults to: `[ 'file://', 'capacitor://' ]`. */ this.loaderLocalScheme = GetValue(config, 'loader.localScheme', [ 'file://', 'capacitor://' ]); /** * @const {number} Phaser.Core.Config#glowFXQuality - The quality of the Glow FX (defaults to 0.1) */ this.glowFXQuality = GetValue(config, 'fx.glow.quality', 0.1); /** * @const {number} Phaser.Core.Config#glowFXDistance - The distance of the Glow FX (defaults to 10) */ this.glowFXDistance = GetValue(config, 'fx.glow.distance', 10); /* * Allows `plugins` property to either be an array, in which case it just replaces * the default plugins like previously, or a config object. * * plugins: { * global: [ * { key: 'TestPlugin', plugin: TestPlugin, start: true, data: { msg: 'The plugin is alive' } }, * ], * scene: [ * { key: 'WireFramePlugin', plugin: WireFramePlugin, systemKey: 'wireFramePlugin', sceneKey: 'wireframe' } * ], * default: [], OR * defaultMerge: [ * 'ModPlayer' * ] * } */ /** * @const {any} Phaser.Core.Config#installGlobalPlugins - An array of global plugins to be installed. */ this.installGlobalPlugins = []; /** * @const {any} Phaser.Core.Config#installScenePlugins - An array of Scene level plugins to be installed. */ this.installScenePlugins = []; var plugins = GetValue(config, 'plugins', null); var defaultPlugins = DefaultPlugins.DefaultScene; if (plugins) { // Old 3.7 array format? if (Array.isArray(plugins)) { this.defaultPlugins = plugins; } else if (IsPlainObject(plugins)) { this.installGlobalPlugins = GetFastValue(plugins, 'global', []); this.installScenePlugins = GetFastValue(plugins, 'scene', []); if (Array.isArray(plugins.default)) { defaultPlugins = plugins.default; } else if (Array.isArray(plugins.defaultMerge)) { defaultPlugins = defaultPlugins.concat(plugins.defaultMerge); } } } /** * @const {any} Phaser.Core.Config#defaultPlugins - The plugins installed into every Scene (in addition to CoreScene and Global). */ this.defaultPlugins = defaultPlugins; // Default / Missing Images var pngPrefix = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg'; /** * @const {string} Phaser.Core.Config#defaultImage - A base64 encoded PNG that will be used as the default blank texture. */ this.defaultImage = GetValue(config, 'images.default', pngPrefix + 'AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=='); /** * @const {string} Phaser.Core.Config#missingImage - A base64 encoded PNG that will be used as the default texture when a texture is assigned that is missing or not loaded. */ this.missingImage = GetValue(config, 'images.missing', pngPrefix + 'CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg=='); /** * @const {string} Phaser.Core.Config#whiteImage - A base64 encoded PNG that will be used as the default texture when a texture is assigned that is white or not loaded. */ this.whiteImage = GetValue(config, 'images.white', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABdJREFUeNpi/P//PwMMMDEgAdwcgAADAJZuAwXJYZOzAAAAAElFTkSuQmCC'); if (window) { if (window.FORCE_WEBGL) { this.renderType = CONST.WEBGL; } else if (window.FORCE_CANVAS) { this.renderType = CONST.CANVAS; } } } }); module.exports = Config; /***/ }), /***/ 86054: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var CanvasInterpolation = __webpack_require__(20623); var CanvasPool = __webpack_require__(27919); var CONST = __webpack_require__(8054); var Features = __webpack_require__(89357); /** * 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.Core.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; if ((config.customEnvironment || config.canvas) && config.renderType === CONST.AUTO) { throw new Error('Must set explicit renderType in custom environment'); } // Not a custom environment, didn't provide their own canvas and not headless, so determine the renderer: if (!config.customEnvironment && !config.canvas && config.renderType !== CONST.HEADLESS) { if (config.renderType === CONST.AUTO) { config.renderType = Features.webGL ? CONST.WEBGL : CONST.CANVAS; } if (config.renderType === CONST.WEBGL) { if (!Features.webGL) { throw new Error('Cannot create WebGL context, aborting.'); } } else if (config.renderType === CONST.CANVAS) { if (!Features.canvas) { throw new Error('Cannot create Canvas context, aborting.'); } } else { throw new Error('Unknown value for renderer type: ' + config.renderType); } } // Pixel Art mode? if (!config.antialias) { CanvasPool.disableSmoothing(); } var baseSize = game.scale.baseSize; var width = baseSize.width; var height = baseSize.height; // Does the game config provide its own canvas element to use? if (config.canvas) { game.canvas = config.canvas; game.canvas.width = width; game.canvas.height = height; } else { game.canvas = CanvasPool.create(game, width, 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.antialias) { CanvasInterpolation.setCrisp(game.canvas); } if (config.renderType === CONST.HEADLESS) { // Nothing more to do here return; } var CanvasRenderer; var WebGLRenderer; if (true) { CanvasRenderer = __webpack_require__(68627); WebGLRenderer = __webpack_require__(74797); // Let the config pick the renderer type, as both are included if (config.renderType === CONST.WEBGL) { game.renderer = new WebGLRenderer(game); } else { game.renderer = new CanvasRenderer(game); game.context = game.renderer.gameContext; } } if (false) {} if (false) {} }; module.exports = CreateRenderer; /***/ }), /***/ 96391: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var CONST = __webpack_require__(8054); /** * 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.Core.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.disableWebAudio) { audioType = 'Web Audio'; } else if (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 transparent to support different browser themes) args.push('background: transparent'); if (config.gameTitle) { c = c.concat(config.gameTitle); if (config.gameVersion) { c = c.concat(' v' + config.gameVersion); } if (!config.hidePhaser) { c = c.concat(' / '); } } var fb = ( false) ? 0 : ''; if (!config.hidePhaser) { c = c.concat('Phaser v' + CONST.VERSION + fb + ' (' + 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; /***/ }), /***/ 50127: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var AddToDOM = __webpack_require__(40366); var AnimationManager = __webpack_require__(60848); var CacheManager = __webpack_require__(24047); var CanvasPool = __webpack_require__(27919); var Class = __webpack_require__(83419); var Config = __webpack_require__(69547); var CreateDOMContainer = __webpack_require__(83719); var CreateRenderer = __webpack_require__(86054); var DataManager = __webpack_require__(45893); var DebugHeader = __webpack_require__(96391); var Device = __webpack_require__(82264); var DOMContentLoaded = __webpack_require__(57264); var EventEmitter = __webpack_require__(50792); var Events = __webpack_require__(8443); var InputManager = __webpack_require__(7003); var PluginCache = __webpack_require__(37277); var PluginManager = __webpack_require__(77332); var ScaleManager = __webpack_require__(76531); var SceneManager = __webpack_require__(60903); var TextureEvents = __webpack_require__(69442); var TextureManager = __webpack_require__(17130); var TimeStep = __webpack_require__(65898); var VisibilityHandler = __webpack_require__(51085); if (true) { var SoundManagerCreator = __webpack_require__(14747); } if (false) { var FacebookInstantGamesPlugin; } /** * @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 * @fires Phaser.Core.Events#BLUR * @fires Phaser.Core.Events#FOCUS * @fires Phaser.Core.Events#HIDDEN * @fires Phaser.Core.Events#VISIBLE * @since 3.0.0 * * @param {Phaser.Types.Core.GameConfig} [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.Core.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 an HTML Div Element used as the DOM Element Container. * * Only set if `createDOMContainer` is `true` in the game config (by default it is `false`) and * if you provide a parent element to insert the Phaser Game inside. * * See the DOM Element Game Object for more details. * * @name Phaser.Game#domContainer * @type {HTMLDivElement} * @since 3.17.0 */ this.domContainer = null; /** * A reference to the HTML Canvas Element that Phaser uses to render the game. * This is created automatically by Phaser unless you provide a `canvas` property * in your Game Config. * * @name Phaser.Game#canvas * @type {HTMLCanvasElement} * @since 3.0.0 */ this.canvas = null; /** * A reference to the Rendering Context belonging to the Canvas Element this game is rendering to. * If the game is running under Canvas it will be a 2d Canvas Rendering Context. * If the game is running under WebGL it will be a WebGL Rendering Context. * This context is created automatically by Phaser unless you provide a `context` property * in your Game Config. * * @name Phaser.Game#context * @type {(CanvasRenderingContext2D|WebGLRenderingContext)} * @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 {Phaser.Events.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); /** * An instance of the Data Manager. This is a global manager, available from any Scene * and allows you to share and exchange your own game-level data or events without having * to use an internal event system. * * @name Phaser.Game#registry * @type {Phaser.Data.DataManager} * @since 3.0.0 */ this.registry = new DataManager(this, new EventEmitter()); /** * 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 Scale Manager. * * The Scale Manager is a global system responsible for handling scaling of the game canvas. * * @name Phaser.Game#scale * @type {Phaser.Scale.ScaleManager} * @since 3.16.0 */ this.scale = new ScaleManager(this, this.config); /** * 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. * * You can disable the inclusion of the Sound Manager in your build by toggling the webpack `FEATURE_SOUND` flag. * * @name Phaser.Game#sound * @type {(Phaser.Sound.NoAudioSoundManager|Phaser.Sound.HTML5AudioSoundManager|Phaser.Sound.WebAudioSoundManager)} * @since 3.0.0 */ this.sound = null; if (true) { 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.Core.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.Plugins.PluginManager} * @since 3.0.0 */ this.plugins = new PluginManager(this, this.config); if (false) {} /** * Is this Game pending destruction at the start of the next frame? * * @name Phaser.Game#pendingDestroy * @type {boolean} * @private * @since 3.5.0 */ this.pendingDestroy = false; /** * Remove the Canvas once the destroy is over? * * @name Phaser.Game#removeCanvas * @type {boolean} * @private * @since 3.5.0 */ this.removeCanvas = false; /** * Remove everything when the game is destroyed. * You cannot create a new Phaser instance on the same web page after doing this. * * @name Phaser.Game#noReturn * @type {boolean} * @private * @since 3.12.0 */ this.noReturn = false; /** * Does the window the game is running in currently have focus or not? * This is modified by the VisibilityHandler. * * @name Phaser.Game#hasFocus * @type {boolean} * @readonly * @since 3.9.0 */ this.hasFocus = false; /** * Is the Game currently paused? This will stop everything from updating, * except the `TimeStep` and related RequestAnimationFrame or setTimeout. * Those will continue stepping, but the core Game step will be skipped. * * @name Phaser.Game#isPaused * @type {boolean} * @since 3.60.0 */ this.isPaused = false; // Wait for the DOM Ready event, then call boot. DOMContentLoaded(this.boot.bind(this)); }, /** * 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.Core.Events#BOOT * @listens Phaser.Textures.Events#READY * @since 3.0.0 */ boot: function () { if (!PluginCache.hasCore('EventEmitter')) { console.warn('Aborting. Core Plugins missing.'); return; } this.isBooted = true; this.config.preBoot(this); this.scale.preBoot(); CreateRenderer(this); CreateDOMContainer(this); DebugHeader(this); AddToDOM(this.canvas, this.config.parent); // The Texture Manager has to wait on a couple of non-blocking events before it's fully ready. // So it will emit this internal event when done: this.textures.once(TextureEvents.READY, this.texturesReady, this); this.events.emit(Events.BOOT); if (false) {} }, /** * Called automatically when the Texture Manager has finished setting up and preparing the * default textures. * * @method Phaser.Game#texturesReady * @private * @fires Phaser.Game#READY * @since 3.12.0 */ texturesReady: function () { // Start all the other systems this.events.emit(Events.READY); this.start(); }, /** * 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); var eventEmitter = this.events; eventEmitter.on(Events.HIDDEN, this.onHidden, this); eventEmitter.on(Events.VISIBLE, this.onVisible, this); eventEmitter.on(Events.BLUR, this.onBlur, this); eventEmitter.on(Events.FOCUS, this.onFocus, this); }, /** * 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.Core.Events#PRE_STEP * @fires Phaser.Core.Events#STEP * @fires Phaser.Core.Events#POST_STEP * @fires Phaser.Core.Events#PRE_RENDER * @fires Phaser.Core.Events#POST_RENDER * @since 3.0.0 * * @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} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ step: function (time, delta) { if (this.pendingDestroy) { return this.runDestroy(); } if (this.isPaused) { return; } var eventEmitter = this.events; // Global Managers like Input and Sound update in the prestep eventEmitter.emit(Events.PRE_STEP, time, delta); // This is mostly meant for user-land code and plugins eventEmitter.emit(Events.STEP, time, delta); // Update the Scene Manager and all active Scenes this.scene.update(time, delta); // Our final event before rendering starts eventEmitter.emit(Events.POST_STEP, time, delta); var renderer = this.renderer; // Run the Pre-render (clearing the canvas, setting background colors, etc) renderer.preRender(); eventEmitter.emit(Events.PRE_RENDER, renderer, time, delta); // The main render loop. Iterates all Scenes and all Cameras in those scenes, rendering to the renderer instance. this.scene.render(renderer); // The Post-Render call. Tidies up loose end, takes snapshots, etc. renderer.postRender(); // The final event before the step repeats. Your last chance to do anything to the canvas before it all starts again. eventEmitter.emit(Events.POST_RENDER, renderer, time, delta); }, /** * 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#PRE_RENDER * @fires Phaser.Game#POST_RENDER * @since 3.2.0 * * @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} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ headlessStep: function (time, delta) { if (this.pendingDestroy) { return this.runDestroy(); } if (this.isPaused) { return; } var eventEmitter = this.events; // Global Managers like Input and Sound update in the prestep eventEmitter.emit(Events.PRE_STEP, time, delta); // This is mostly meant for user-land code and plugins eventEmitter.emit(Events.STEP, time, delta); // Update the Scene Manager and all active Scenes this.scene.update(time, delta); // Our final event before rendering starts eventEmitter.emit(Events.POST_STEP, time, delta); // Render this.scene.isProcessing = false; eventEmitter.emit(Events.PRE_RENDER, null, time, delta); eventEmitter.emit(Events.POST_RENDER, null, time, delta); }, /** * 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.Core.Events#PAUSE * @since 3.0.0 */ onHidden: function () { this.loop.pause(); this.events.emit(Events.PAUSE); }, /** * This will pause the entire game and emit a `PAUSE` event. * * All of Phaser's internal systems will be paused and the game will not re-render. * * Note that it does not pause any Loader requests that are currently in-flight. * * @method Phaser.Game#pause * @fires Phaser.Core.Events#PAUSE * @since 3.60.0 */ pause: function () { var wasPaused = this.isPaused; this.isPaused = true; if (!wasPaused) { this.events.emit(Events.PAUSE); } }, /** * 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.Core.Events#RESUME * @since 3.0.0 */ onVisible: function () { this.loop.resume(); this.events.emit(Events.RESUME, this.loop.pauseDuration); }, /** * This will resume the entire game and emit a `RESUME` event. * * All of Phaser's internal systems will be resumed and the game will start rendering again. * * @method Phaser.Game#resume * @fires Phaser.Core.Events#RESUME * @since 3.60.0 */ resume: function () { var wasPaused = this.isPaused; this.isPaused = false; if (wasPaused) { this.events.emit(Events.RESUME, 0); } }, /** * 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.hasFocus = false; 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.hasFocus = true; this.loop.focus(); }, /** * Returns the current game frame. * * When the game starts running, the frame is incremented every time Request Animation Frame, or Set Timeout, fires. * * @method Phaser.Game#getFrame * @since 3.16.0 * * @return {number} The current game frame. */ getFrame: function () { return this.loop.frame; }, /** * Returns the time that the current game step started at, as based on `performance.now`. * * @method Phaser.Game#getTime * @since 3.16.0 * * @return {number} The current game timestamp. */ getTime: function () { return this.loop.now; }, /** * Flags this Game instance as needing to be destroyed on the _next frame_, making this an asynchronous operation. * * It will wait until the current frame has completed and then call `runDestroy` internally. * * If you need to react to the games eventual destruction, listen for the `DESTROY` event. * * If you **do not** need to run Phaser again on the same web page you can set the `noReturn` argument to `true` and it will free-up * memory being held by the core Phaser plugins. If you do need to create another game instance on the same page, leave this as `false`. * * @method Phaser.Game#destroy * @fires Phaser.Core.Events#DESTROY * @since 3.0.0 * * @param {boolean} removeCanvas - Set to `true` if you would like the parent canvas element removed from the DOM, or `false` to leave it in place. * @param {boolean} [noReturn=false] - If `true` all the core Phaser plugins are destroyed. You cannot create another instance of Phaser on the same web page if you do this. */ destroy: function (removeCanvas, noReturn) { if (noReturn === undefined) { noReturn = false; } this.pendingDestroy = true; this.removeCanvas = removeCanvas; this.noReturn = noReturn; }, /** * Destroys this Phaser.Game instance, all global systems, all sub-systems and all Scenes. * * @method Phaser.Game#runDestroy * @private * @since 3.5.0 */ runDestroy: function () { this.scene.destroy(); this.events.emit(Events.DESTROY); this.events.removeAllListeners(); if (this.renderer) { this.renderer.destroy(); } if (this.removeCanvas && this.canvas) { CanvasPool.remove(this.canvas); if (this.canvas.parentNode) { this.canvas.parentNode.removeChild(this.canvas); } } if (this.domContainer && this.domContainer.parentNode) { this.domContainer.parentNode.removeChild(this.domContainer); } this.loop.destroy(); this.pendingDestroy = false; } }); module.exports = Game; /** * "Computers are good at following instructions, but not at reading your mind." - Donald Knuth */ /***/ }), /***/ 65898: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Class = __webpack_require__(83419); var GetValue = __webpack_require__(35154); var NOOP = __webpack_require__(29747); var RequestAnimationFrame = __webpack_require__(43092); // http://www.testufo.com/#test=animation-time-graph /** * @classdesc * The core runner class that Phaser uses to handle the game loop. It can use either Request Animation Frame, * or SetTimeout, based on browser support and config settings, to create a continuous loop within the browser. * * Each time the loop fires, `TimeStep.step` is called and this is then passed onto the core Game update loop, * it is the core heartbeat of your game. It will fire as often as Request Animation Frame is capable of handling * on the target device. * * Note that there are lots of situations where a browser will stop updating your game. Such as if the player * switches tabs, or covers up the browser window with another application. In these cases, the 'heartbeat' * of your game will pause, and only resume when focus is returned to it by the player. There is no way to avoid * this situation, all you can do is use the visibility events the browser, and Phaser, provide to detect when * it has happened and then gracefully recover. * * @class TimeStep * @memberof Phaser.Core * @constructor * @since 3.0.0 * * @param {Phaser.Game} game - A reference to the Phaser.Game instance that owns this Time Step. * @param {Phaser.Types.Core.FPSConfig} config */ var TimeStep = new Class({ initialize: function TimeStep (game, config) { /** * A reference to the Phaser.Game instance. * * @name Phaser.Core.TimeStep#game * @type {Phaser.Game} * @readonly * @since 3.0.0 */ this.game = game; /** * The Request Animation Frame DOM Event handler. * * @name Phaser.Core.TimeStep#raf * @type {Phaser.DOM.RequestAnimationFrame} * @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. * * @name Phaser.Core.TimeStep#started * @type {boolean} * @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. * * @name Phaser.Core.TimeStep#running * @type {boolean} * @readonly * @default false * @since 3.0.0 */ this.running = false; /** * The minimum fps rate you want the Time Step to run at. * * Setting this cannot guarantee the browser runs at this rate, it merely influences * the internal timing values to help the Timestep know when it has gone out of sync. * * @name Phaser.Core.TimeStep#minFps * @type {number} * @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. * * @name Phaser.Core.TimeStep#targetFps * @type {number} * @default 60 * @since 3.0.0 */ this.targetFps = GetValue(config, 'target', 60); /** * Enforce a frame rate limit. This forces how often the Game step will run. By default it is zero, * which means it will run at whatever limit the browser (via RequestAnimationFrame) can handle, which * is the optimum rate for fast-action or responsive games. * * However, if you are building a non-game app, like a graphics generator, or low-intensity game that doesn't * require 60fps, then you can lower the step rate via this Game Config value: * * ```js * fps: { * limit: 30 * } * ``` * * Setting this _beyond_ the rate of RequestAnimationFrame will make no difference at all. * * Use it purely to _restrict_ updates in low-intensity situations only. * * @name Phaser.Core.TimeStep#fpsLimit * @type {number} * @default 0 * @since 3.60.0 */ this.fpsLimit = GetValue(config, 'limit', 0); /** * Is the FPS rate limited? * * This is set by setting the Game Config `limit` value to a value above zero. * * Consider this property as read-only. * * @name Phaser.Core.TimeStep#hasFpsLimit * @type {boolean} * @default false * @since 3.60.0 */ this.hasFpsLimit = (this.fpsLimit > 0); /** * Internal value holding the fps rate limit in ms. * * @name Phaser.Core.TimeStep#_limitRate * @type {number} * @private * @since 3.60.0 */ this._limitRate = (this.hasFpsLimit) ? (1000 / this.fpsLimit) : 0; /** * The minimum fps value in ms. * * Defaults to 200ms between frames (i.e. super slow!) * * @name Phaser.Core.TimeStep#_min * @type {number} * @private * @since 3.0.0 */ this._min = 1000 / this.minFps; /** * The target fps value in ms. * * Defaults to 16.66ms between frames (i.e. normal) * * @name Phaser.Core.TimeStep#_target * @type {number} * @private * @since 3.0.0 */ this._target = 1000 / this.targetFps; /** * An exponential moving average of the frames per second. * * @name Phaser.Core.TimeStep#actualFps * @type {number} * @readonly * @default 60 * @since 3.0.0 */ this.actualFps = this.targetFps; /** * The time at which the next fps rate update will take place. * * When an fps update happens, the `framesThisSecond` value is reset. * * @name Phaser.Core.TimeStep#nextFpsUpdate * @type {number} * @readonly * @default 0 * @since 3.0.0 */ this.nextFpsUpdate = 0; /** * The number of frames processed this second. * * @name Phaser.Core.TimeStep#framesThisSecond * @type {number} * @readonly * @default 0 * @since 3.0.0 */ this.framesThisSecond = 0; /** * A callback to be invoked each time the TimeStep steps. * * @name Phaser.Core.TimeStep#callback * @type {Phaser.Types.Core.TimeStepCallback} * @default NOOP * @since 3.0.0 */ this.callback = NOOP; /** * You can force the TimeStep to use SetTimeOut instead of Request Animation Frame by setting * the `forceSetTimeOut` property to `true` in the Game Configuration object. It cannot be changed at run-time. * * @name Phaser.Core.TimeStep#forceSetTimeOut * @type {boolean} * @readonly * @default false * @since 3.0.0 */ this.forceSetTimeOut = GetValue(config, 'forceSetTimeOut', false); /** * The time, updated each step by adding the elapsed delta time to the previous value. * * This differs from the `TimeStep.now` value, which is the high resolution time value * as provided by Request Animation Frame. * * @name Phaser.Core.TimeStep#time * @type {number} * @default 0 * @since 3.0.0 */ this.time = 0; /** * The time at which the game started running. * * This value is adjusted if the game is then paused and resumes. * * @name Phaser.Core.TimeStep#startTime * @type {number} * @default 0 * @since 3.0.0 */ this.startTime = 0; /** * The time of the previous step. * * This is typically a high resolution timer value, as provided by Request Animation Frame. * * @name Phaser.Core.TimeStep#lastTime * @type {number} * @default 0 * @since 3.0.0 */ this.lastTime = 0; /** * The current frame the game is on. This counter is incremented once every game step, regardless of how much * time has passed and is unaffected by delta smoothing. * * @name Phaser.Core.TimeStep#frame * @type {number} * @readonly * @default 0 * @since 3.0.0 */ this.frame = 0; /** * Is the browser currently considered in focus by the Page Visibility API? * * This value is set in the `blur` method, which is called automatically by the Game instance. * * @name Phaser.Core.TimeStep#inFocus * @type {boolean} * @readonly * @default true * @since 3.0.0 */ this.inFocus = true; /** * The duration of the most recent game pause, if any, in ms. * * @name Phaser.Core.TimeStep#pauseDuration * @type {number} * @readonly * @default 0 * @since 3.85.0 */ this.pauseDuration = 0; /** * The timestamp at which the game became paused, as determined by the Page Visibility API. * * @name Phaser.Core.TimeStep#_pauseTime * @type {number} * @private * @default 0 * @since 3.0.0 */ this._pauseTime = 0; /** * An internal counter to allow for the browser 'cooling down' after coming back into focus. * * @name Phaser.Core.TimeStep#_coolDown * @type {number} * @private * @default 0 * @since 3.0.0 */ this._coolDown = 0; /** * The delta time, in ms, since the last game step. This is a clamped and smoothed average value. * * @name Phaser.Core.TimeStep#delta * @type {number} * @default 0 * @since 3.0.0 */ this.delta = 0; /** * Internal index of the delta history position. * * @name Phaser.Core.TimeStep#deltaIndex * @type {number} * @default 0 * @since 3.0.0 */ this.deltaIndex = 0; /** * Internal array holding the previous delta values, used for delta smoothing. * * @name Phaser.Core.TimeStep#deltaHistory * @type {number[]} * @since 3.0.0 */ this.deltaHistory = []; /** * The maximum number of delta values that are retained in order to calculate a smoothed moving average. * * This can be changed in the Game Config via the `fps.deltaHistory` property. The default is 10. * * @name Phaser.Core.TimeStep#deltaSmoothingMax * @type {number} * @default 10 * @since 3.0.0 */ this.deltaSmoothingMax = GetValue(config, 'deltaHistory', 10); /** * The number of frames that the cooldown is set to after the browser panics over the FPS rate, usually * as a result of switching tabs and regaining focus. * * This can be changed in the Game Config via the `fps.panicMax` property. The default is 120. * * @name Phaser.Core.TimeStep#panicMax * @type {number} * @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 math calculations. * * @name Phaser.Core.TimeStep#rawDelta * @type {number} * @default 0 * @since 3.0.0 */ this.rawDelta = 0; /** * The time, set at the start of the current step. * * This is typically a high resolution timer value, as provided by Request Animation Frame. * * This can differ from the `time` value in that it isn't calculated based on the delta value. * * @name Phaser.Core.TimeStep#now * @type {number} * @default 0 * @since 3.18.0 */ this.now = 0; /** * Apply smoothing to the delta value used within Phasers internal calculations? * * This can be changed in the Game Config via the `fps.smoothStep` property. The default is `true`. * * Smoothing helps settle down the delta values after browser tab switches, or other situations * which could cause significant delta spikes or dips. By default it has been enabled in Phaser 3 * since the first version, but is now exposed under this property (and the corresponding game config * `smoothStep` value), to allow you to easily disable it, should you require. * * @name Phaser.Core.TimeStep#smoothStep * @type {boolean} * @since 3.22.0 */ this.smoothStep = GetValue(config, 'smoothStep', true); }, /** * Called by the Game instance when the DOM window.onBlur event triggers. * * @method Phaser.Core.TimeStep#blur * @since 3.0.0 */ blur: function () { this.inFocus = false; }, /** * Called by the Game instance when the DOM window.onFocus event triggers. * * @method Phaser.Core.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.Core.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.Core.TimeStep#resume * @since 3.0.0 */ resume: function () { this.resetDelta(); this.pauseDuration = this.time - this._pauseTime; this.startTime += this.pauseDuration; }, /** * Resets the time, lastTime, fps averages and delta history. * Called automatically when a browser sleeps them resumes. * * @method Phaser.Core.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; // 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.Core.TimeStep#start * @since 3.0.0 * * @param {Phaser.Types.Core.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; var step = (this.hasFpsLimit) ? this.stepLimitFPS.bind(this) : this.step.bind(this); this.raf.start(step, this.forceSetTimeOut, this._target); }, /** * Takes the delta value and smooths it based on the previous frames. * * Called automatically as part of the step. * * @method Phaser.Core.TimeStep#smoothDelta * @since 3.60.0 * * @param {number} delta - The delta value for this step. * * @return {number} The smoothed delta value. */ smoothDelta: function (delta) { var idx = this.deltaIndex; var history = this.deltaHistory; var max = this.deltaSmoothingMax; if (this._coolDown > 0 || !this.inFocus) { this._coolDown--; delta = Math.min(delta, this._target); } if (delta > this._min) { // Probably super bad start time or browser tab context loss, // so use the last 'sane' delta value delta = history[idx]; // Clamp delta to min (in case history has become corrupted somehow) delta = Math.min(delta, this._min); } // Smooth out the delta over the previous X frames // add the delta to the smoothing array history[idx] = delta; // 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; } // Loop the history array, adding the delta values together var avg = 0; for (var i = 0; i < max; i++) { avg += history[i]; } // Then divide by the array length to get the average delta avg /= max; return avg; }, /** * 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. * * Compute the new exponential moving average with an alpha of 0.25. * * @method Phaser.Core.TimeStep#updateFPS * @since 3.60.0 * * @param {number} time - The timestamp passed in from RequestAnimationFrame or setTimeout. */ updateFPS: function (time) { this.actualFps = 0.25 * this.framesThisSecond + 0.75 * this.actualFps; this.nextFpsUpdate = time + 1000; this.framesThisSecond = 0; }, /** * The main step method with an fps limiter. 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.Core.TimeStep#stepLimitFPS * @since 3.60.0 * * @param {number} time - The timestamp passed in from RequestAnimationFrame or setTimeout. */ stepLimitFPS: function (time) { this.now = time; // delta time (time is in ms) // Math.max because Chrome will sometimes give negative deltas var delta = Math.max(0, time - this.lastTime); this.rawDelta = delta; // Real-world timer advance this.time += this.rawDelta; if (this.smoothStep) { delta = this.smoothDelta(delta); } // Set as the world delta value (after smoothing, if applied) this.delta += delta; if (time >= this.nextFpsUpdate) { this.updateFPS(time); } this.framesThisSecond++; if (this.delta >= this._limitRate) { this.callback(time, this.delta); this.delta = 0; } // Shift time value over this.lastTime = time; this.frame++; }, /** * 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.Core.TimeStep#step * @since 3.0.0 * * @param {number} time - The timestamp passed in from RequestAnimationFrame or setTimeout. */ step: function (time) { this.now = time; // delta time (time is in ms) // Math.max because Chrome will sometimes give negative deltas var delta = Math.max(0, time - this.lastTime); this.rawDelta = delta; // Real-world timer advance this.time += this.rawDelta; if (this.smoothStep) { delta = this.smoothDelta(delta); } // Set as the world delta value (after smoothing, if applied) this.delta = delta; if (time >= this.nextFpsUpdate) { this.updateFPS(time); } this.framesThisSecond++; this.callback(time, delta); // Shift time value over this.lastTime = time; this.frame++; }, /** * Manually calls `TimeStep.step`. * * @method Phaser.Core.TimeStep#tick * @since 3.0.0 */ tick: function () { var now = window.performance.now(); if (this.hasFpsLimit) { this.stepLimitFPS(now); } else { this.step(now); } }, /** * Sends the TimeStep to sleep, stopping Request Animation Frame (or SetTimeout) and toggling the `running` flag to false. * * @method Phaser.Core.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.Core.TimeStep#wake * @since 3.0.0 * * @param {boolean} [seamless=false] - Adjust the startTime based on the lastTime values. */ wake: function (seamless) { if (seamless === undefined) { seamless = false; } var now = window.performance.now(); if (this.running) { return; } else if (seamless) { this.startTime += -this.lastTime + (this.lastTime + now); } var step = (this.hasFpsLimit) ? this.stepLimitFPS.bind(this) : this.step.bind(this); this.raf.start(step, this.forceSetTimeOut, this._target); this.running = true; this.nextFpsUpdate = now + 1000; this.framesThisSecond = 0; this.fpsLimitTriggered = false; this.tick(); }, /** * Gets the duration which the game has been running, in seconds. * * @method Phaser.Core.TimeStep#getDuration * @since 3.17.0 * * @return {number} The duration in seconds. */ getDuration: function () { return Math.round(this.lastTime - this.startTime) / 1000; }, /** * Gets the duration which the game has been running, in ms. * * @method Phaser.Core.TimeStep#getDurationMS * @since 3.17.0 * * @return {number} The duration in ms. */ getDurationMS: function () { return Math.round(this.lastTime - this.startTime); }, /** * Stops the TimeStep running. * * @method Phaser.Core.TimeStep#stop * @since 3.0.0 * * @return {this} 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.Core.TimeStep#destroy * @since 3.0.0 */ destroy: function () { this.stop(); this.raf.destroy(); this.raf = null; this.game = null; this.callback = null; } }); module.exports = TimeStep; /***/ }), /***/ 51085: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Events = __webpack_require__(8443); /** * 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.Core.VisibilityHandler * @fires Phaser.Core.Events#BLUR * @fires Phaser.Core.Events#FOCUS * @fires Phaser.Core.Events#HIDDEN * @fires Phaser.Core.Events#VISIBLE * @since 3.0.0 * * @param {Phaser.Game} game - The Game instance this Visibility Handler is working on. */ var VisibilityHandler = function (game) { var hiddenVar; var eventEmitter = game.events; 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(Events.HIDDEN); } else { eventEmitter.emit(Events.VISIBLE); } }; if (hiddenVar) { document.addEventListener(hiddenVar, onChange, false); } window.onblur = function () { eventEmitter.emit(Events.BLUR); }; window.onfocus = function () { eventEmitter.emit(Events.FOCUS); }; // Automatically give the window focus unless config says otherwise if (window.focus && game.config.autoFocus) { window.focus(); } }; module.exports = VisibilityHandler; /***/ }), /***/ 97217: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Game Blur Event. * * This event is dispatched by the Game Visibility Handler when the window in which the Game instance is embedded * enters a blurred state. The blur event is raised when the window loses focus. This can happen if a user swaps * tab, or if they simply remove focus from the browser to another app. * * @event Phaser.Core.Events#BLUR * @type {string} * @since 3.0.0 */ module.exports = 'blur'; /***/ }), /***/ 47548: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Game Boot Event. * * This event is dispatched when the Phaser Game instance 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.Core.Events#BOOT * @type {string} * @since 3.0.0 */ module.exports = 'boot'; /***/ }), /***/ 19814: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Game Context Lost Event. * * This event is dispatched by the Game if the WebGL Renderer it is using encounters a WebGL Context Lost event from the browser. * * The renderer halts all rendering and cannot resume after this happens. * * @event Phaser.Core.Events#CONTEXT_LOST * @type {string} * @since 3.19.0 */ module.exports = 'contextlost'; /***/ }), /***/ 68446: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Game Destroy Event. * * This event is dispatched when the game instance has been told to destroy itself. * Lots of internal systems listen to this event in order to clear themselves out. * Custom plugins and game code should also do the same. * * @event Phaser.Core.Events#DESTROY * @type {string} * @since 3.0.0 */ module.exports = 'destroy'; /***/ }), /***/ 41700: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Game Focus Event. * * This event is dispatched by the Game Visibility Handler when the window in which the Game instance is embedded * enters a focused state. The focus event is raised when the window re-gains focus, having previously lost it. * * @event Phaser.Core.Events#FOCUS * @type {string} * @since 3.0.0 */ module.exports = 'focus'; /***/ }), /***/ 25432: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Game Hidden Event. * * This event is dispatched by the Game Visibility Handler when the document in which the Game instance is embedded * enters a hidden state. Only browsers that support the Visibility API will cause this event to be emitted. * * In most modern browsers, when the document enters a hidden state, the Request Animation Frame and setTimeout, which * control the main game loop, will automatically pause. There is no way to stop this from happening. It is something * your game should account for in its own code, should the pause be an issue (i.e. for multiplayer games) * * @event Phaser.Core.Events#HIDDEN * @type {string} * @since 3.0.0 */ module.exports = 'hidden'; /***/ }), /***/ 65942: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The 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.Core.Events#PAUSE * @type {string} * @since 3.0.0 */ module.exports = 'pause'; /***/ }), /***/ 59211: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Game Post-Render Event. * * This event is dispatched right at the end of the render process. * * Every Scene will have rendered and been drawn to the canvas by the time this event is fired. * Use it for any last minute post-processing before the next game step begins. * * @event Phaser.Core.Events#POST_RENDER * @type {string} * @since 3.0.0 * * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - A reference to the current renderer being used by the Game instance. */ module.exports = 'postrender'; /***/ }), /***/ 47789: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Game Post-Step Event. * * This event is dispatched after the Scene Manager has updated. * Hook into it from plugins or systems that need to do things before the render starts. * * @event Phaser.Core.Events#POST_STEP * @type {string} * @since 3.0.0 * * @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} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ module.exports = 'poststep'; /***/ }), /***/ 39066: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The 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.Core.Events#PRE_RENDER * @type {string} * @since 3.0.0 * * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - A reference to the current renderer being used by the Game instance. */ module.exports = 'prerender'; /***/ }), /***/ 460: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Game Pre-Step Event. * * This event is dispatched before the main Game Step starts. By this point in the game cycle none of the Scene updates have yet happened. * Hook into it from plugins or systems that need to update before the Scene Manager does. * * @event Phaser.Core.Events#PRE_STEP * @type {string} * @since 3.0.0 * * @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} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ module.exports = 'prestep'; /***/ }), /***/ 16175: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Game Ready Event. * * This event is dispatched when the Phaser Game instance has finished booting, the Texture Manager is fully ready, * and all local systems are now able to start. * * @event Phaser.Core.Events#READY * @type {string} * @since 3.0.0 */ module.exports = 'ready'; /***/ }), /***/ 42331: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Game Resume Event. * * This event is dispatched when the game loop leaves a paused state and resumes running. * * @event Phaser.Core.Events#RESUME * @type {string} * @since 3.0.0 * * @param {number} pauseDuration - The duration, in ms, that the game was paused for, or 0 if {@link Phaser.Game#resume} was called. */ module.exports = 'resume'; /***/ }), /***/ 11966: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Game Step Event. * * This event is dispatched after the Game Pre-Step and before the Scene Manager steps. * Hook into it from plugins or systems that need to update before the Scene Manager does, but after the core Systems have. * * @event Phaser.Core.Events#STEP * @type {string} * @since 3.0.0 * * @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} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ module.exports = 'step'; /***/ }), /***/ 32969: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * This event is dispatched when the Scene Manager has created the System Scene, * which other plugins and systems may use to initialize themselves. * * This event is dispatched just once by the Game instance. * * @event Phaser.Core.Events#SYSTEM_READY * @type {string} * @since 3.70.0 * * @param {Phaser.Scenes.Systems} sys - A reference to the Scene Systems class of the Scene that emitted this event. */ module.exports = 'systemready'; /***/ }), /***/ 94830: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Game Visible Event. * * This event is dispatched by the Game Visibility Handler when the document in which the Game instance is embedded * enters a visible state, previously having been hidden. * * Only browsers that support the Visibility API will cause this event to be emitted. * * @event Phaser.Core.Events#VISIBLE * @type {string} * @since 3.0.0 */ module.exports = 'visible'; /***/ }), /***/ 8443: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Core.Events */ module.exports = { BLUR: __webpack_require__(97217), BOOT: __webpack_require__(47548), CONTEXT_LOST: __webpack_require__(19814), DESTROY: __webpack_require__(68446), FOCUS: __webpack_require__(41700), HIDDEN: __webpack_require__(25432), PAUSE: __webpack_require__(65942), POST_RENDER: __webpack_require__(59211), POST_STEP: __webpack_require__(47789), PRE_RENDER: __webpack_require__(39066), PRE_STEP: __webpack_require__(460), READY: __webpack_require__(16175), RESUME: __webpack_require__(42331), STEP: __webpack_require__(11966), SYSTEM_READY: __webpack_require__(32969), VISIBLE: __webpack_require__(94830) }; /***/ }), /***/ 42857: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Core */ module.exports = { Config: __webpack_require__(69547), CreateRenderer: __webpack_require__(86054), DebugHeader: __webpack_require__(96391), Events: __webpack_require__(8443), TimeStep: __webpack_require__(65898), VisibilityHandler: __webpack_require__(51085) }; /***/ }), /***/ 99584: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Arne16 = __webpack_require__(5290); var CanvasPool = __webpack_require__(27919); var GetValue = __webpack_require__(35154); /** * Generates a texture based on the given Create configuration object. * * The texture is drawn using a fixed-size indexed palette of 16 colors, where the hex value in the * data cells map to a single color. For example, if the texture config looked like this: * * ```javascript * var star = [ * '.....828.....', * '....72227....', * '....82228....', * '...7222227...', * '2222222222222', * '8222222222228', * '.72222222227.', * '..787777787..', * '..877777778..', * '.78778887787.', * '.27887.78872.', * '.787.....787.' * ]; * * this.textures.generate('star', { data: star, pixelWidth: 4 }); * ``` * * Then it would generate a texture that is 52 x 48 pixels in size, because each cell of the data array * represents 1 pixel multiplied by the `pixelWidth` value. The cell values, such as `8`, maps to color * number 8 in the palette. If a cell contains a period character `.` then it is transparent. * * The default palette is Arne16, but you can specify your own using the `palette` property. * * @function Phaser.Create.GenerateTexture * @since 3.0.0 * * @param {Phaser.Types.Create.GenerateTextureConfig} config - The Generate Texture Configuration object. * * @return {HTMLCanvasElement} An HTMLCanvasElement which contains the generated texture drawn to it. */ 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', { willReadFrequently: true }); 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; /***/ }), /***/ 15822: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Create */ module.exports = { GenerateTexture: __webpack_require__(99584), Palettes: __webpack_require__(57763) }; /***/ }), /***/ 5290: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * A 16 color palette by [Arne](http://androidarts.com/palette/16pal.htm) * * @name Phaser.Create.Palettes.ARNE16 * @since 3.0.0 * * @type {Phaser.Types.Create.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' }; /***/ }), /***/ 23816: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * A 16 color palette inspired by the Commodore 64. * * @name Phaser.Create.Palettes.C64 * @since 3.0.0 * * @type {Phaser.Types.Create.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' }; /***/ }), /***/ 9866: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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 {Phaser.Types.Create.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' }; /***/ }), /***/ 77552: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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 {Phaser.Types.Create.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' }; /***/ }), /***/ 92259: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * A 16 color palette inspired by Japanese computers like the MSX. * * @name Phaser.Create.Palettes.MSX * @since 3.0.0 * * @type {Phaser.Types.Create.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' }; /***/ }), /***/ 57763: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Create.Palettes */ module.exports = { ARNE16: __webpack_require__(5290), C64: __webpack_require__(23816), CGA: __webpack_require__(9866), JMP: __webpack_require__(77552), MSX: __webpack_require__(92259) }; /***/ }), /***/ 46728: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ // Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) var Class = __webpack_require__(83419); var CubicBezier = __webpack_require__(36316); var Curve = __webpack_require__(80021); var Vector2 = __webpack_require__(26099); /** * @classdesc * A higher-order Bézier curve constructed of four points. * * @class CubicBezier * @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]); } /** * The start point of this curve. * * @name Phaser.Curves.CubicBezier#p0 * @type {Phaser.Math.Vector2} * @since 3.0.0 */ this.p0 = p0; /** * The first control point of this curve. * * @name Phaser.Curves.CubicBezier#p1 * @type {Phaser.Math.Vector2} * @since 3.0.0 */ this.p1 = p1; /** * The second control point of this curve. * * @name Phaser.Curves.CubicBezier#p2 * @type {Phaser.Math.Vector2} * @since 3.0.0 */ this.p2 = p2; /** * The end point of this curve. * * @name Phaser.Curves.CubicBezier#p3 * @type {Phaser.Math.Vector2} * @since 3.0.0 */ this.p3 = p3; }, /** * Gets the starting point on the curve. * * @method Phaser.Curves.CubicBezier#getStartPoint * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @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); }, /** * Returns the resolution of this curve. * * @method Phaser.Curves.CubicBezier#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.CubicBezier#getPoint * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {number} 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)); }, /** * Draws this curve to the specified graphics object. * * @method Phaser.Curves.CubicBezier#draw * @since 3.0.0 * * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] * * @param {Phaser.GameObjects.Graphics} graphics - The graphics object this curve should be drawn to. * @param {number} [pointsTotal=32] - The number of intermediary points that make up this curve. A higher number of points will result in a smoother curve. * * @return {Phaser.GameObjects.Graphics} The graphics object this curve was drawn to. Useful for method chaining. */ 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; }, /** * Returns a JSON object that describes this curve. * * @method Phaser.Curves.CubicBezier#toJSON * @since 3.0.0 * * @return {Phaser.Types.Curves.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 ] }; } }); /** * Generates a curve from a JSON object. * * @function Phaser.Curves.CubicBezier.fromJSON * @since 3.0.0 * * @param {Phaser.Types.Curves.JSONCurve} data - The JSON object containing this curve data. * * @return {Phaser.Curves.CubicBezier} The curve generated from the JSON object. */ 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; /***/ }), /***/ 80021: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Class = __webpack_require__(83419); var FromPoints = __webpack_require__(19217); var Rectangle = __webpack_require__(87841); var Vector2 = __webpack_require__(26099); /** * @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 - The curve type. */ 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 {number} * @default 5 * @since 3.0.0 */ this.defaultDivisions = 5; /** * The quantity of arc length divisions within the curve. * * @name Phaser.Curves.Curve#arcLengthDivisions * @type {number} * @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; /** * For a curve on a Path, `false` means the Path will ignore this curve. * * @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 * * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] * * @param {Phaser.GameObjects.Graphics} graphics - The Graphics instance onto which this curve will be drawn. * @param {number} [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 {number} [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 {number} 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); }, /** * Get a point at the end of the curve. * * @method Phaser.Curves.Curve#getEndPoint * @since 3.0.0 * * @param {Phaser.Math.Vector2} [out] - Optional Vector object to store the result in. * * @return {Phaser.Math.Vector2} Vector2 containing the coordinates of the curves end point. */ getEndPoint: function (out) { if (out === undefined) { out = new Vector2(); } return this.getPointAt(1, out); }, /** * Get total curve arc length * * @method Phaser.Curves.Curve#getLength * @since 3.0.0 * * @return {number} The total length of the curve. */ getLength: function () { var lengths = this.getLengths(); return lengths[lengths.length - 1]; }, /** * Get a list of cumulative segment lengths. * * These lengths are * * - [0] 0 * - [1] The first segment * - [2] The first and second segment * - ... * - [divisions] All segments * * @method Phaser.Curves.Curve#getLengths * @since 3.0.0 * * @param {number} [divisions] - The number of divisions or segments. * * @return {number[]} An array of cumulative lengths. */ 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] /** * Get a point at a relative position on the curve, by arc length. * * @method Phaser.Curves.Curve#getPointAt * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {number} u - The relative position, [0..1]. * @param {Phaser.Math.Vector2} [out] - A point to store the result in. * * @return {Phaser.Math.Vector2} The point. */ getPointAt: function (u, out) { var t = this.getUtoTmapping(u); return this.getPoint(t, out); }, // Get sequence of points using getPoint( t ) /** * Get a sequence of evenly spaced points from the curve. * * You can pass `divisions`, `stepRate`, or neither. * * The number of divisions will be * * 1. `divisions`, if `divisions` > 0; or * 2. `this.getLength / stepRate`, if `stepRate` > 0; or * 3. `this.defaultDivisions` * * `1 + divisions` points will be returned. * * @method Phaser.Curves.Curve#getPoints * @since 3.0.0 * * @generic {Phaser.Math.Vector2[]} O - [out,$return] * * @param {number} [divisions] - The number of divisions to make. * @param {number} [stepRate] - The curve distance between points, implying `divisions`. * @param {(array|Phaser.Math.Vector2[])} [out] - An optional array to store the points in. * * @return {(array|Phaser.Math.Vector2[])} An array of Points from the curve. */ getPoints: function (divisions, stepRate, out) { if (out === undefined) { out = []; } // If divisions is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. if (!divisions) { if (!stepRate) { divisions = this.defaultDivisions; } else { divisions = this.getLength() / stepRate; } } for (var d = 0; d <= divisions; d++) { out.push(this.getPoint(d / divisions)); } return out; }, /** * Get a random point from the curve. * * @method Phaser.Curves.Curve#getRandomPoint * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {Phaser.Math.Vector2} [out] - A point object to store the result in. * * @return {Phaser.Math.Vector2} The point. */ getRandomPoint: function (out) { if (out === undefined) { out = new Vector2(); } return this.getPoint(Math.random(), out); }, // Get sequence of points using getPointAt( u ) /** * Get a sequence of equally spaced points (by arc distance) from the curve. * * `1 + divisions` points will be returned. * * @method Phaser.Curves.Curve#getSpacedPoints * @since 3.0.0 * * @param {number} [divisions=this.defaultDivisions] - The number of divisions to make. * @param {number} [stepRate] - Step between points. Used to calculate the number of points to return when divisions is falsy. Ignored if divisions is positive. * @param {(array|Phaser.Math.Vector2[])} [out] - An optional array to store the points in. * * @return {Phaser.Math.Vector2[]} An array of points. */ getSpacedPoints: function (divisions, stepRate, out) { if (out === undefined) { out = []; } // If divisions is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. if (!divisions) { if (!stepRate) { divisions = this.defaultDivisions; } else { divisions = this.getLength() / stepRate; } } for (var d = 0; d <= divisions; d++) { var t = this.getUtoTmapping(d / divisions, null, divisions); out.push(this.getPoint(t)); } return out; }, /** * Get a point at the start of the curve. * * @method Phaser.Curves.Curve#getStartPoint * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {Phaser.Math.Vector2} [out] - A point to store the result in. * * @return {Phaser.Math.Vector2} The point. */ getStartPoint: function (out) { if (out === undefined) { out = new Vector2(); } return this.getPointAt(0, out); }, /** * Get a unit vector tangent at a relative position on the curve. * 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 * * @method Phaser.Curves.Curve#getTangent * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {number} t - The relative position on the curve, [0..1]. * @param {Phaser.Math.Vector2} [out] - A vector to store the result in. * * @return {Phaser.Math.Vector2} Vector approximating the tangent line at the point t (delta +/- 0.0001) */ 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(); }, /** * Get a unit vector tangent at a relative position on the curve, by arc length. * * @method Phaser.Curves.Curve#getTangentAt * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {number} u - The relative position on the curve, [0..1]. * @param {Phaser.Math.Vector2} [out] - A vector to store the result in. * * @return {Phaser.Math.Vector2} The tangent vector. */ 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. * * @method Phaser.Curves.Curve#getTFromDistance * @since 3.0.0 * * @param {number} distance - The distance, in pixels. * @param {number} [divisions] - Optional amount of divisions. * * @return {number} The distance. */ 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. * * @method Phaser.Curves.Curve#getUtoTmapping * @since 3.0.0 * * @param {number} u - A float between 0 and 1. * @param {number} distance - The distance, in pixels. * @param {number} [divisions] - Optional amount of divisions. * * @return {number} The equidistant value. */ 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); }, /** * Calculate and cache the arc lengths. * * @method Phaser.Curves.Curve#updateArcLengths * @since 3.0.0 * * @see Phaser.Curves.Curve#getLengths() */ updateArcLengths: function () { this.needsUpdate = true; this.getLengths(); } }); module.exports = Curve; /***/ }), /***/ 73825: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ // Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) var Class = __webpack_require__(83419); var Curve = __webpack_require__(80021); var DegToRad = __webpack_require__(39506); var GetValue = __webpack_require__(35154); var RadToDeg = __webpack_require__(43396); var Vector2 = __webpack_require__(26099); /** * @classdesc * An Elliptical Curve derived from the Base Curve class. * * See https://en.wikipedia.org/wiki/Elliptic_curve for more details. * * @class Ellipse * @extends Phaser.Curves.Curve * @memberof Phaser.Curves * @constructor * @since 3.0.0 * * @param {(number|Phaser.Types.Curves.EllipseCurveConfig)} [x=0] - The x coordinate of the ellipse, or an Ellipse Curve configuration object. * @param {number} [y=0] - The y coordinate of the ellipse. * @param {number} [xRadius=0] - The horizontal radius of ellipse. * @param {number} [yRadius=0] - The vertical radius of ellipse. * @param {number} [startAngle=0] - The start angle of the ellipse, in degrees. * @param {number} [endAngle=360] - The end angle of the ellipse, in degrees. * @param {boolean} [clockwise=false] - Whether the ellipse angles are given as clockwise (`true`) or counter-clockwise (`false`). * @param {number} [rotation=0] - The rotation of the ellipse, in degrees. */ 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 /** * The center point of the ellipse. Used for calculating rotation. * * @name Phaser.Curves.Ellipse#p0 * @type {Phaser.Math.Vector2} * @since 3.0.0 */ this.p0 = new Vector2(x, y); /** * The horizontal radius of the ellipse. * * @name Phaser.Curves.Ellipse#_xRadius * @type {number} * @private * @since 3.0.0 */ this._xRadius = xRadius; /** * The vertical radius of the ellipse. * * @name Phaser.Curves.Ellipse#_yRadius * @type {number} * @private * @since 3.0.0 */ this._yRadius = yRadius; // Radians /** * The starting angle of the ellipse in radians. * * @name Phaser.Curves.Ellipse#_startAngle * @type {number} * @private * @since 3.0.0 */ this._startAngle = DegToRad(startAngle); /** * The end angle of the ellipse in radians. * * @name Phaser.Curves.Ellipse#_endAngle * @type {number} * @private * @since 3.0.0 */ this._endAngle = DegToRad(endAngle); /** * Anti-clockwise direction. * * @name Phaser.Curves.Ellipse#_clockwise * @type {boolean} * @private * @since 3.0.0 */ this._clockwise = clockwise; /** * The rotation of the arc. * * @name Phaser.Curves.Ellipse#_rotation * @type {number} * @private * @since 3.0.0 */ this._rotation = DegToRad(rotation); }, /** * Gets the starting point on the curve. * * @method Phaser.Curves.Ellipse#getStartPoint * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @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); }, /** * Get the resolution of the curve. * * @method Phaser.Curves.Ellipse#getResolution * @since 3.0.0 * * @param {number} divisions - Optional divisions value. * * @return {number} The curve resolution. */ getResolution: function (divisions) { return divisions * 2; }, /** * Get point at relative position in curve according to length. * * @method Phaser.Curves.Ellipse#getPoint * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {number} 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.Ellipse#setXRadius * @since 3.0.0 * * @param {number} value - The horizontal radius of this curve. * * @return {this} This curve object. */ setXRadius: function (value) { this.xRadius = value; return this; }, /** * Sets the vertical radius of this curve. * * @method Phaser.Curves.Ellipse#setYRadius * @since 3.0.0 * * @param {number} value - The vertical radius of this curve. * * @return {this} This curve object. */ setYRadius: function (value) { this.yRadius = value; return this; }, /** * Sets the width of this curve. * * @method Phaser.Curves.Ellipse#setWidth * @since 3.0.0 * * @param {number} value - The width of this curve. * * @return {this} This curve object. */ setWidth: function (value) { this.xRadius = value / 2; return this; }, /** * Sets the height of this curve. * * @method Phaser.Curves.Ellipse#setHeight * @since 3.0.0 * * @param {number} value - The height of this curve. * * @return {this} This curve object. */ setHeight: function (value) { this.yRadius = value / 2; return this; }, /** * Sets the start angle of this curve. * * @method Phaser.Curves.Ellipse#setStartAngle * @since 3.0.0 * * @param {number} value - The start angle of this curve, in radians. * * @return {this} This curve object. */ setStartAngle: function (value) { this.startAngle = value; return this; }, /** * Sets the end angle of this curve. * * @method Phaser.Curves.Ellipse#setEndAngle * @since 3.0.0 * * @param {number} value - The end angle of this curve, in radians. * * @return {this} This curve object. */ setEndAngle: function (value) { this.endAngle = value; return this; }, /** * Sets if this curve extends clockwise or anti-clockwise. * * @method Phaser.Curves.Ellipse#setClockwise * @since 3.0.0 * * @param {boolean} value - The clockwise state of this curve. * * @return {this} This curve object. */ setClockwise: function (value) { this.clockwise = value; return this; }, /** * Sets the rotation of this curve. * * @method Phaser.Curves.Ellipse#setRotation * @since 3.0.0 * * @param {number} value - The rotation of this curve, in radians. * * @return {this} This curve object. */ setRotation: function (value) { this.rotation = value; return this; }, /** * The x coordinate of the center of the ellipse. * * @name Phaser.Curves.Ellipse#x * @type {number} * @since 3.0.0 */ x: { get: function () { return this.p0.x; }, set: function (value) { this.p0.x = value; } }, /** * The y coordinate of the center of the ellipse. * * @name Phaser.Curves.Ellipse#y * @type {number} * @since 3.0.0 */ y: { get: function () { return this.p0.y; }, set: function (value) { this.p0.y = value; } }, /** * The horizontal radius of the ellipse. * * @name Phaser.Curves.Ellipse#xRadius * @type {number} * @since 3.0.0 */ xRadius: { get: function () { return this._xRadius; }, set: function (value) { this._xRadius = value; } }, /** * The vertical radius of the ellipse. * * @name Phaser.Curves.Ellipse#yRadius * @type {number} * @since 3.0.0 */ yRadius: { get: function () { return this._yRadius; }, set: function (value) { this._yRadius = value; } }, /** * The start angle of the ellipse in degrees. * * @name Phaser.Curves.Ellipse#startAngle * @type {number} * @since 3.0.0 */ startAngle: { get: function () { return RadToDeg(this._startAngle); }, set: function (value) { this._startAngle = DegToRad(value); } }, /** * The end angle of the ellipse in degrees. * * @name Phaser.Curves.Ellipse#endAngle * @type {number} * @since 3.0.0 */ endAngle: { get: function () { return RadToDeg(this._endAngle); }, set: function (value) { this._endAngle = DegToRad(value); } }, /** * `true` if the ellipse rotation is clockwise or `false` if anti-clockwise. * * @name Phaser.Curves.Ellipse#clockwise * @type {boolean} * @since 3.0.0 */ clockwise: { get: function () { return this._clockwise; }, set: function (value) { this._clockwise = value; } }, /** * The rotation of the ellipse, relative to the center, in degrees. * * @name Phaser.Curves.Ellipse#angle * @type {number} * @since 3.14.0 */ angle: { get: function () { return RadToDeg(this._rotation); }, set: function (value) { this._rotation = DegToRad(value); } }, /** * The rotation of the ellipse, relative to the center, in radians. * * @name Phaser.Curves.Ellipse#rotation * @type {number} * @since 3.0.0 */ rotation: { get: function () { return this._rotation; }, set: function (value) { this._rotation = value; } }, /** * JSON serialization of the curve. * * @method Phaser.Curves.Ellipse#toJSON * @since 3.0.0 * * @return {Phaser.Types.Curves.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) }; } }); /** * Creates a curve from the provided Ellipse Curve Configuration object. * * @function Phaser.Curves.Ellipse.fromJSON * @since 3.0.0 * * @param {Phaser.Types.Curves.JSONEllipseCurve} data - The JSON object containing this curve data. * * @return {Phaser.Curves.Ellipse} The ellipse curve constructed from the configuration object. */ EllipseCurve.fromJSON = function (data) { return new EllipseCurve(data); }; module.exports = EllipseCurve; /***/ }), /***/ 33951: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ // Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) var Class = __webpack_require__(83419); var Curve = __webpack_require__(80021); var FromPoints = __webpack_require__(19217); var Rectangle = __webpack_require__(87841); var Vector2 = __webpack_require__(26099); /** * @classdesc * A LineCurve is a "curve" comprising exactly two points (a line segment). * * @class Line * @extends Phaser.Curves.Curve * @memberof Phaser.Curves * @constructor * @since 3.0.0 * * @param {(Phaser.Math.Vector2|number[])} p0 - The first endpoint. * @param {Phaser.Math.Vector2} [p1] - The second endpoint. */ 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]); } /** * The first endpoint. * * @name Phaser.Curves.Line#p0 * @type {Phaser.Math.Vector2} * @since 3.0.0 */ this.p0 = p0; /** * The second endpoint. * * @name Phaser.Curves.Line#p1 * @type {Phaser.Math.Vector2} * @since 3.0.0 */ this.p1 = p1; // Override default Curve.arcLengthDivisions /** * The quantity of arc length divisions within the curve. * * @name Phaser.Curves.Line#arcLengthDivisions * @type {number} * @default 1 * @since 3.0.0 */ this.arcLengthDivisions = 1; }, /** * Returns a Rectangle where the position and dimensions match the bounds of this Curve. * * @method Phaser.Curves.Line#getBounds * @since 3.0.0 * * @generic {Phaser.Geom.Rectangle} O - [out,$return] * * @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.Line#getStartPoint * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @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); }, /** * Gets the resolution of the line. * * @method Phaser.Curves.Line#getResolution * @since 3.0.0 * * @param {number} [divisions=1] - The number of divisions to consider. * * @return {number} The resolution. Equal to the number of divisions. */ getResolution: function (divisions) { if (divisions === undefined) { divisions = 1; } return divisions; }, /** * Get point at relative position in curve according to length. * * @method Phaser.Curves.Line#getPoint * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {number} 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 /** * Gets a point at a given position on the line. * * @method Phaser.Curves.Line#getPointAt * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {number} 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); }, /** * Gets the slope of the line as a unit vector. * * @method Phaser.Curves.Line#getTangent * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {number} [t] - The relative position on the line, [0..1]. * @param {Phaser.Math.Vector2} [out] - A vector to store the result in. * * @return {Phaser.Math.Vector2} The tangent vector. */ getTangent: function (t, out) { if (out === undefined) { out = new Vector2(); } out.copy(this.p1).subtract(this.p0).normalize(); return out; }, /** * Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant. * * @method Phaser.Curves.Line#getUtoTmapping * @since 3.0.0 * * @param {number} u - A float between 0 and 1. * @param {number} distance - The distance, in pixels. * @param {number} [divisions] - Optional amount of divisions. * * @return {number} The equidistant value. */ getUtoTmapping: function (u, distance, divisions) { var t; if (distance) { var arcLengths = this.getLengths(divisions); var lineLength = arcLengths[arcLengths.length - 1]; // Cannot overshoot the curve var targetLineLength = Math.min(distance, lineLength); t = targetLineLength / lineLength; } else { t = u; } return t; }, // 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.Line#draw * @since 3.0.0 * * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] * * @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; }, /** * Gets a JSON representation of the line. * * @method Phaser.Curves.Line#toJSON * @since 3.0.0 * * @return {Phaser.Types.Curves.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 ] }; } }); /** * Configures this line from a JSON representation. * * @function Phaser.Curves.Line.fromJSON * @since 3.0.0 * * @param {Phaser.Types.Curves.JSONCurve} data - The JSON object containing this curve data. * * @return {Phaser.Curves.Line} A new LineCurve object. */ 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; /***/ }), /***/ 14744: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Class = __webpack_require__(83419); var Curve = __webpack_require__(80021); var QuadraticBezierInterpolation = __webpack_require__(32112); var Vector2 = __webpack_require__(26099); /** * @classdesc * A quadratic Bézier curve constructed from two control points. * * @class QuadraticBezier * @extends Phaser.Curves.Curve * @memberof Phaser.Curves * @constructor * @since 3.2.0 * * @param {(Phaser.Math.Vector2|number[])} 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, 'QuadraticBezierCurve'); 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]); } /** * The start point. * * @name Phaser.Curves.QuadraticBezier#p0 * @type {Phaser.Math.Vector2} * @since 3.2.0 */ this.p0 = p0; /** * The first control point. * * @name Phaser.Curves.QuadraticBezier#p1 * @type {Phaser.Math.Vector2} * @since 3.2.0 */ this.p1 = p1; /** * The second control point. * * @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 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @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); }, /** * Get the resolution of the curve. * * @method Phaser.Curves.QuadraticBezier#getResolution * @since 3.2.0 * * @param {number} divisions - Optional divisions value. * * @return {number} The curve resolution. */ getResolution: function (divisions) { return divisions; }, /** * Get point at relative position in curve according to length. * * @method Phaser.Curves.QuadraticBezier#getPoint * @since 3.2.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {number} 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) ); }, /** * 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.QuadraticBezier#draw * @since 3.2.0 * * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] * * @param {Phaser.GameObjects.Graphics} graphics - `Graphics` object to draw onto. * @param {number} [pointsTotal=32] - Number of points to be used for drawing the curve. Higher numbers result in smoother curve but require more processing. * * @return {Phaser.GameObjects.Graphics} `Graphics` object that was drawn to. */ 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; }, /** * Converts the curve into a JSON compatible object. * * @method Phaser.Curves.QuadraticBezier#toJSON * @since 3.2.0 * * @return {Phaser.Types.Curves.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 ] }; } }); /** * Creates a curve from a JSON object, e. g. created by `toJSON`. * * @function Phaser.Curves.QuadraticBezier.fromJSON * @since 3.2.0 * * @param {Phaser.Types.Curves.JSONCurve} data - The JSON object containing this curve data. * * @return {Phaser.Curves.QuadraticBezier} The created curve instance. */ 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; /***/ }), /***/ 42534: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ // Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) var CatmullRom = __webpack_require__(87842); var Class = __webpack_require__(83419); var Curve = __webpack_require__(80021); var Vector2 = __webpack_require__(26099); /** * @classdesc * Create a smooth 2d spline curve from a series of points. * * @class Spline * @extends Phaser.Curves.Curve * @memberof Phaser.Curves * @constructor * @since 3.0.0 * * @param {(Phaser.Math.Vector2[]|number[]|number[][])} [points] - The points that configure the curve. */ var SplineCurve = new Class({ Extends: Curve, initialize: function SplineCurve (points) { if (points === undefined) { points = []; } Curve.call(this, 'SplineCurve'); /** * The Vector2 points that configure the curve. * * @name Phaser.Curves.Spline#points * @type {Phaser.Math.Vector2[]} * @default [] * @since 3.0.0 */ this.points = []; this.addPoints(points); }, /** * Add a list of points to the current list of Vector2 points of the curve. * * @method Phaser.Curves.Spline#addPoints * @since 3.0.0 * * @param {(Phaser.Math.Vector2[]|number[]|number[][])} points - The points that configure the curve. * * @return {this} 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; }, /** * Add a point to the current list of Vector2 points of the curve. * * @method Phaser.Curves.Spline#addPoint * @since 3.0.0 * * @param {number} x - The x coordinate of this curve * @param {number} y - The y coordinate of this curve * * @return {Phaser.Math.Vector2} The new Vector2 added to the curve */ 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.Spline#getStartPoint * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @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]); }, /** * Get the resolution of the curve. * * @method Phaser.Curves.Spline#getResolution * @since 3.0.0 * * @param {number} divisions - Optional divisions value. * * @return {number} The curve resolution. */ getResolution: function (divisions) { return divisions * this.points.length; }, /** * Get point at relative position in curve according to length. * * @method Phaser.Curves.Spline#getPoint * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {number} 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)); }, /** * Exports a JSON object containing this curve data. * * @method Phaser.Curves.Spline#toJSON * @since 3.0.0 * * @return {Phaser.Types.Curves.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 }; } }); /** * Imports a JSON object containing this curve data. * * @function Phaser.Curves.Spline.fromJSON * @since 3.0.0 * * @param {Phaser.Types.Curves.JSONCurve} data - The JSON object containing this curve data. * * @return {Phaser.Curves.Spline} The spline curve created. */ SplineCurve.fromJSON = function (data) { return new SplineCurve(data.points); }; module.exports = SplineCurve; /***/ }), /***/ 25410: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Curves */ module.exports = { Path: __webpack_require__(46669), MoveTo: __webpack_require__(68618), CubicBezier: __webpack_require__(46728), Curve: __webpack_require__(80021), Ellipse: __webpack_require__(73825), Line: __webpack_require__(33951), QuadraticBezier: __webpack_require__(14744), Spline: __webpack_require__(42534) }; /***/ }), /***/ 68618: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Class = __webpack_require__(83419); var Vector2 = __webpack_require__(26099); /** * @classdesc * A MoveTo Curve is a very simple curve consisting of only a single point. * Its intended use is to move the ending point in a Path. * * @class MoveTo * @memberof Phaser.Curves * @constructor * @since 3.0.0 * * @param {number} [x=0] - `x` pixel coordinate. * @param {number} [y=0] - `y` pixel coordinate. */ var MoveTo = new Class({ initialize: function MoveTo (x, y) { /** * Denotes that this Curve does not influence the bounds, points, and drawing of its parent Path. Must be `false` or some methods in the parent Path will throw errors. * * @name Phaser.Curves.MoveTo#active * @type {boolean} * @default false * @since 3.0.0 */ this.active = false; /** * The lone point which this curve consists of. * * @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 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {number} 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); }, /** * Retrieves the point at given position in the curve. This will always return this curve's only point. * * @method Phaser.Curves.MoveTo#getPointAt * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {number} u - The position in the path to retrieve, between 0 and 1. Not used. * @param {Phaser.Math.Vector2} [out] - An optional vector in which to store the point. * * @return {Phaser.Math.Vector2} The modified `out` vector, or a new `Vector2` if none was provided. */ 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; }, /** * Converts this curve into a JSON-serializable object. * * @method Phaser.Curves.MoveTo#toJSON * @since 3.0.0 * * @return {Phaser.Types.Curves.JSONCurve} A primitive object with the curve's type and only point. */ toJSON: function () { return { type: 'MoveTo', points: [ this.p0.x, this.p0.y ] }; } }); module.exports = MoveTo; /***/ }), /***/ 46669: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ // Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) var Class = __webpack_require__(83419); var CubicBezierCurve = __webpack_require__(46728); var EllipseCurve = __webpack_require__(73825); var GameObjectFactory = __webpack_require__(39429); var LineCurve = __webpack_require__(33951); var MovePathTo = __webpack_require__(68618); var QuadraticBezierCurve = __webpack_require__(14744); var Rectangle = __webpack_require__(87841); var SplineCurve = __webpack_require__(42534); var Vector2 = __webpack_require__(26099); var MATH_CONST = __webpack_require__(36383); /** * @classdesc * A Path combines multiple Curves into one continuous compound curve. * It does not matter how many Curves are in the Path or what type they are. * * A Curve in a Path does not have to start where the previous Curve ends - that is to say, a Path does not * have to be an uninterrupted curve. Only the order of the Curves influences the actual points on the Path. * * @class Path * @memberof Phaser.Curves * @constructor * @since 3.0.0 * * @param {number} [x=0] - The X coordinate of the Path's starting point or a {@link Phaser.Types.Curves.JSONPath}. * @param {number} [y=0] - The Y coordinate of the Path's starting point. */ var Path = new Class({ initialize: function Path (x, y) { if (x === undefined) { x = 0; } if (y === undefined) { y = 0; } /** * The name of this Path. * Empty by default and never populated by Phaser, this is left for developers to use. * * @name Phaser.Curves.Path#name * @type {string} * @default '' * @since 3.0.0 */ this.name = ''; /** * The default number of divisions within a curve. * * @name Phaser.Curves.Path#defaultDivisions * @type {number} * @default 12 * @since 3.70.0 */ this.defaultDivisions = 12; /** * The list of Curves which make up this Path. * * @name Phaser.Curves.Path#curves * @type {Phaser.Curves.Curve[]} * @default [] * @since 3.0.0 */ this.curves = []; /** * The cached length of each Curve in the Path. * * Used internally by {@link #getCurveLengths}. * * @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; /** * The starting point of the Path. * * This is not necessarily equivalent to the starting point of the first Curve in the Path. In an empty Path, it's also treated as the ending point. * * @name Phaser.Curves.Path#startPoint * @type {Phaser.Math.Vector2} * @since 3.0.0 */ this.startPoint = new Vector2(); /** * A temporary vector used to avoid object creation when adding a Curve to the Path. * * @name Phaser.Curves.Path#_tmpVec2A * @type {Phaser.Math.Vector2} * @private * @since 3.0.0 */ this._tmpVec2A = new Vector2(); /** * A temporary vector used to avoid object creation when adding a Curve to the Path. * * @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); } }, /** * Appends a Curve to the end of the Path. * * The Curve does not have to start where the Path ends or, for an empty Path, at its defined starting point. * * @method Phaser.Curves.Path#add * @since 3.0.0 * * @param {Phaser.Curves.Curve} curve - The Curve to append. * * @return {this} This Path object. */ add: function (curve) { this.curves.push(curve); return this; }, /** * Creates a circular Ellipse Curve positioned at the end of the Path. * * @method Phaser.Curves.Path#circleTo * @since 3.0.0 * * @param {number} radius - The radius of the circle. * @param {boolean} [clockwise=false] - `true` to create a clockwise circle as opposed to a counter-clockwise circle. * @param {number} [rotation=0] - The rotation of the circle in degrees. * * @return {this} This Path object. */ circleTo: function (radius, clockwise, rotation) { if (clockwise === undefined) { clockwise = false; } return this.ellipseTo(radius, radius, 0, 360, clockwise, rotation); }, /** * Ensures that the Path is closed. * * A closed Path starts and ends at the same point. If the Path is not closed, a straight Line Curve will be created from the ending point directly to the starting point. During the check, the actual starting point of the Path, i.e. the starting point of the first Curve, will be used as opposed to the Path's defined {@link startPoint}, which could differ. * * Calling this method on an empty Path will result in an error. * * @method Phaser.Curves.Path#closePath * @since 3.0.0 * * @return {this} This Path object. */ 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. * * @method Phaser.Curves.Path#cubicBezierTo * @since 3.0.0 * * @param {(number|Phaser.Math.Vector2)} x - The x coordinate of the end point. Or, if a Vector2, the p1 value. * @param {(number|Phaser.Math.Vector2)} y - The y coordinate of the end point. Or, if a Vector2, the p2 value. * @param {(number|Phaser.Math.Vector2)} control1X - The x coordinate of the first control point. Or, if a Vector2, the p3 value. * @param {number} [control1Y] - The y coordinate of the first control point. Not used if Vector2s are provided as the first 3 arguments. * @param {number} [control2X] - The x coordinate of the second control point. Not used if Vector2s are provided as the first 3 arguments. * @param {number} [control2Y] - The y coordinate of the second control point. Not used if Vector2s are provided as the first 3 arguments. * * @return {this} This Path object. */ cubicBezierTo: function (x, y, control1X, control1Y, control2X, control2Y) { var p0 = this.getEndPoint(); var p1; var p2; var p3; // Assume they're all Vector2s 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 /** * Creates a Quadratic Bezier Curve starting at the ending point of the Path. * * @method Phaser.Curves.Path#quadraticBezierTo * @since 3.2.0 * * @param {(number|Phaser.Math.Vector2[])} x - The X coordinate of the second control point or, if it's a `Vector2`, the first control point. * @param {number} [y] - The Y coordinate of the second control point or, if `x` is a `Vector2`, the second control point. * @param {number} [controlX] - If `x` is not a `Vector2`, the X coordinate of the first control point. * @param {number} [controlY] - If `x` is not a `Vector2`, the Y coordinate of the first control point. * * @return {this} This Path object. */ quadraticBezierTo: function (x, y, controlX, controlY) { var p0 = this.getEndPoint(); var p1; var p2; // Assume they're all Vector2s 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)); }, /** * Draws all Curves in the Path to a Graphics Game Object. * * @method Phaser.Curves.Path#draw * @since 3.0.0 * * @generic {Phaser.GameObjects.Graphics} G - [out,$return] * * @param {Phaser.GameObjects.Graphics} graphics - The Graphics Game Object to draw to. * @param {number} [pointsTotal=32] - The number of points to draw for each Curve. Higher numbers result in a smoother curve but require more processing. * * @return {Phaser.GameObjects.Graphics} The Graphics object which was drawn to. */ 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=0] - The horizontal radius of ellipse. * @param {number} [yRadius=0] - The vertical radius of ellipse. * @param {number} [startAngle=0] - The start angle of the ellipse, in degrees. * @param {number} [endAngle=360] - The end angle of the ellipse, in degrees. * @param {boolean} [clockwise=false] - Whether the ellipse angles are given as clockwise (`true`) or counter-clockwise (`false`). * @param {number} [rotation=0] - The rotation of the ellipse, in degrees. * * @return {this} This Path object. */ 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); }, /** * Creates a Path from a Path Configuration object. * * The provided object should be a {@link Phaser.Types.Curves.JSONPath}, as returned by {@link #toJSON}. Providing a malformed object may cause errors. * * @method Phaser.Curves.Path#fromJSON * @since 3.0.0 * * @param {Phaser.Types.Curves.JSONPath} data - The JSON object containing the Path data. * * @return {this} This Path object. */ 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; }, /** * Returns a Rectangle with a position and size matching the bounds of this Path. * * @method Phaser.Curves.Path#getBounds * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {Phaser.Geom.Rectangle} [out] - The Rectangle to store the bounds in. * @param {number} [accuracy=16] - The accuracy of the bounds calculations. Higher values are more accurate at the cost of calculation speed. * * @return {Phaser.Geom.Rectangle} The modified `out` Rectangle, or a new Rectangle if none was provided. */ 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 = MATH_CONST.MIN_SAFE_INTEGER; var maxBottom = MATH_CONST.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; }, /** * Returns an array containing the length of the Path at the end of each Curve. * * The result of this method will be cached to avoid recalculating it in subsequent calls. The cache is only invalidated when the {@link #curves} array changes in length, leading to potential inaccuracies if a Curve in the Path is changed, or if a Curve is removed and another is added in its place. * * @method Phaser.Curves.Path#getCurveLengths * @since 3.0.0 * * @return {number[]} An array containing the length of the Path at the end of each one of its Curves. */ 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; }, /** * Returns the Curve that forms the Path at the given normalized location (between 0 and 1). * * @method Phaser.Curves.Path#getCurveAt * @since 3.60.0 * * @param {number} t - The normalized location on the Path, between 0 and 1. * * @return {?Phaser.Curves.Curve} The Curve that is part of this Path at a given location, or `null` if no curve was found. */ getCurveAt: function (t) { var d = t * this.getLength(); var curveLengths = this.getCurveLengths(); var i = 0; while (i < curveLengths.length) { if (curveLengths[i] >= d) { return this.curves[i]; } i++; } return null; }, /** * Returns the ending point of the Path. * * A Path's ending point is equivalent to the ending point of the last Curve in the Path. For an empty Path, the ending point is at the Path's defined {@link #startPoint}. * * @method Phaser.Curves.Path#getEndPoint * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {Phaser.Math.Vector2} [out] - The object to store the point in. * * @return {Phaser.Math.Vector2} The modified `out` object, or a new Vector2 if none was provided. */ 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; }, /** * Returns the total length of the Path. * * @see {@link #getCurveLengths} * * @method Phaser.Curves.Path#getLength * @since 3.0.0 * * @return {number} The total length of the Path. */ 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') /** * Calculates the coordinates of the point at the given normalized location (between 0 and 1) on the Path. * * The location is relative to the entire Path, not to an individual Curve. A location of 0.5 is always in the middle of the Path and is thus an equal distance away from both its starting and ending points. In a Path with one Curve, it would be in the middle of the Curve; in a Path with two Curves, it could be anywhere on either one of them depending on their lengths. * * @method Phaser.Curves.Path#getPoint * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {number} t - The location of the point to return, between 0 and 1. * @param {Phaser.Math.Vector2} [out] - The object in which to store the calculated point. * * @return {?Phaser.Math.Vector2} The modified `out` object, or a new `Vector2` if none was provided. */ 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; }, /** * Returns a randomly chosen point anywhere on the path. This follows the same rules as `getPoint` in that it may return a point on any Curve inside this path. * * When calling this method multiple times, the points are not guaranteed to be equally spaced spatially. * * @method Phaser.Curves.Path#getRandomPoint * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {Phaser.Math.Vector2} [out] - `Vector2` instance that should be used for storing the result. If `undefined` a new `Vector2` will be created. * * @return {Phaser.Math.Vector2} The modified `out` object, or a new `Vector2` if none was provided. */ getRandomPoint: function (out) { if (out === undefined) { out = new Vector2(); } return this.getPoint(Math.random(), out); }, /** * Divides this Path into a set of equally spaced points, * * The resulting points are equally spaced with respect to the points' position on the path, but not necessarily equally spaced spatially. * * @method Phaser.Curves.Path#getSpacedPoints * @since 3.0.0 * * @param {number} [divisions=40] - The amount of points to divide this Path into. * * @return {Phaser.Math.Vector2[]} A list of the points this path was subdivided into. */ 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; }, /** * Returns the starting point of the Path. * * @method Phaser.Curves.Path#getStartPoint * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {Phaser.Math.Vector2} [out] - `Vector2` instance that should be used for storing the result. If `undefined` a new `Vector2` will be created. * * @return {Phaser.Math.Vector2} The modified `out` object, or a new Vector2 if none was provided. */ getStartPoint: function (out) { if (out === undefined) { out = new Vector2(); } return out.copy(this.startPoint); }, /** * Gets a unit vector tangent at a relative position on the path. * * @method Phaser.Curves.Path#getTangent * @since 3.23.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {number} t - The relative position on the path, [0..1]. * @param {Phaser.Math.Vector2} [out] - A vector to store the result in. * * @return {Phaser.Math.Vector2} Vector approximating the tangent line at the point t (delta +/- 0.0001) */ getTangent: 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.getTangentAt(u, out); } i++; } return null; }, /** * Creates a line curve from the previous end point to x/y. * * @method Phaser.Curves.Path#lineTo * @since 3.0.0 * * @param {(number|Phaser.Math.Vector2|Phaser.Types.Math.Vector2Like)} x - The X coordinate of the line's end point, or a `Vector2` / `Vector2Like` containing the entire end point. * @param {number} [y] - The Y coordinate of the line's end point, if a number was passed as the X parameter. * * @return {this} This Path object. */ lineTo: function (x, y) { if (x instanceof Vector2) { this._tmpVec2B.copy(x); } else if (typeof x === 'object') { this._tmpVec2B.setFromObject(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 points on the curve. * * @method Phaser.Curves.Path#splineTo * @since 3.0.0 * * @param {Phaser.Math.Vector2[]} points - The points the newly created spline curve should consist of. * * @return {this} This Path object. */ splineTo: function (points) { points.unshift(this.getEndPoint()); return this.add(new SplineCurve(points)); }, /** * Creates a "gap" in this path from the path's current end point to the given coordinates. * * After calling this function, this Path's end point will be equal to the given coordinates * * @method Phaser.Curves.Path#moveTo * @since 3.0.0 * * @param {(number|Phaser.Math.Vector2|Phaser.Types.Math.Vector2Like)} x - The X coordinate of the position to move the path's end point to, or a `Vector2` / `Vector2Like` containing the entire new end point. * @param {number} [y] - The Y coordinate of the position to move the path's end point to, if a number was passed as the X coordinate. * * @return {this} This Path object. */ moveTo: function (x, y) { if (x instanceof Vector2) { return this.add(new MovePathTo(x.x, x.y)); } else { return this.add(new MovePathTo(x, y)); } }, /** * Converts this Path to a JSON object containing the path information and its constituent curves. * * @method Phaser.Curves.Path#toJSON * @since 3.0.0 * * @return {Phaser.Types.Curves.JSONPath} The JSON object containing this path's data. */ 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. * * @method Phaser.Curves.Path#updateArcLengths * @since 3.0.0 */ updateArcLengths: function () { this.cacheLengths = []; this.getCurveLengths(); }, /** * Disposes of this Path, clearing its internal references to objects so they can be garbage-collected. * * @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; /***/ }), /***/ 45893: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Class = __webpack_require__(83419); var Events = __webpack_require__(24882); /** * @callback DataEachCallback * * @param {*} parent - The parent object of the DataManager. * @param {string} key - The key of the value. * @param {*} value - The value. * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data. */ /** * @classdesc * The Data Manager 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 {object} parent - The object that this DataManager belongs to. * @param {Phaser.Events.EventEmitter} [eventEmitter] - The DataManager's event emitter. */ var DataManager = new Class({ initialize: function DataManager (parent, eventEmitter) { /** * The object that this DataManager belongs to. * * @name Phaser.Data.DataManager#parent * @type {*} * @since 3.0.0 */ this.parent = parent; /** * The DataManager's event emitter. * * @name Phaser.Data.DataManager#events * @type {Phaser.Events.EventEmitter} * @since 3.0.0 */ this.events = eventEmitter; if (!eventEmitter) { this.events = (parent.events) ? parent.events : parent; } /** * The data list. * * @name Phaser.Data.DataManager#list * @type {Object.} * @default {} * @since 3.0.0 */ this.list = {}; /** * The public values list. You can use this to access anything you have stored * in this Data Manager. For example, if you set a value called `gold` you can * access it via: * * ```javascript * this.data.values.gold; * ``` * * You can also modify it directly: * * ```javascript * this.data.values.gold += 1000; * ``` * * Doing so will emit a `setdata` event from the parent of this Data Manager. * * Do not modify this object directly. Adding properties directly to this object will not * emit any events. Always use `DataManager.set` to create new items the first time around. * * @name Phaser.Data.DataManager#values * @type {Object.} * @default {} * @since 3.10.0 */ this.values = {}; /** * Whether setting data is frozen for this DataManager. * * @name Phaser.Data.DataManager#_frozen * @type {boolean} * @private * @default false * @since 3.0.0 */ this._frozen = false; if (!parent.hasOwnProperty('sys') && this.events) { this.events.once(Events.DESTROY, this.destroy, this); } }, /** * Retrieves the value for the given key, or undefined if it doesn't exist. * * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: * * ```javascript * this.data.get('gold'); * ``` * * Or access the value directly: * * ```javascript * this.data.values.gold; * ``` * * You can also pass in an array of keys, in which case an array of values will be returned: * * ```javascript * this.data.get([ 'gold', 'armor', 'health' ]); * ``` * * This approach is useful for destructuring arrays in ES6. * * @method Phaser.Data.DataManager#get * @since 3.0.0 * * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys. * * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array. */ get: function (key) { var list = this.list; if (Array.isArray(key)) { var output = []; for (var i = 0; i < key.length; i++) { output.push(list[key[i]]); } return output; } else { return list[key]; } }, /** * Retrieves all data values in a new object. * * @method Phaser.Data.DataManager#getAll * @since 3.0.0 * * @return {Object.} All data values. */ getAll: function () { var results = {}; for (var key in this.list) { if (this.list.hasOwnProperty(key)) { results[key] = this.list[key]; } } return results; }, /** * Queries the DataManager for the values of keys matching the given regular expression. * * @method Phaser.Data.DataManager#query * @since 3.0.0 * * @param {RegExp} search - A regular expression object. If a non-RegExp object obj is passed, it is implicitly converted to a RegExp by using new RegExp(obj). * * @return {Object.} The values of the keys matching the search string. */ 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; }, /** * Sets a value for the given key. If the key doesn't already exist in the Data Manager then it is created. * * ```javascript * data.set('name', 'Red Gem Stone'); * ``` * * You can also pass in an object of key value pairs as the first argument: * * ```javascript * data.set({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); * ``` * * To get a value back again you can call `get`: * * ```javascript * data.get('gold'); * ``` * * Or you can access the value directly via the `values` property, where it works like any other variable: * * ```javascript * data.values.gold += 50; * ``` * * When the value is first set, a `setdata` event is emitted. * * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata-PlayerLives`. * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. * * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. * * @method Phaser.Data.DataManager#set * @fires Phaser.Data.Events#SET_DATA * @fires Phaser.Data.Events#CHANGE_DATA * @fires Phaser.Data.Events#CHANGE_DATA_KEY * @since 3.0.0 * * @generic {any} T * @genericUse {(string|T)} - [key] * * @param {(string|object)} key - The key to set the value for. Or an object of key value pairs. If an object the `data` argument is ignored. * @param {*} [data] - The value to set for the given key. If an object is provided as the key this argument is ignored. * * @return {this} This Data Manager instance. */ set: function (key, data) { if (this._frozen) { return this; } if (typeof key === 'string') { return this.setValue(key, data); } else { for (var entry in key) { this.setValue(entry, key[entry]); } } return this; }, /** * Increase a value for the given key. If the key doesn't already exist in the Data Manager then it is increased from 0. * * When the value is first set, a `setdata` event is emitted. * * @method Phaser.Data.DataManager#inc * @fires Phaser.Data.Events#SET_DATA * @fires Phaser.Data.Events#CHANGE_DATA * @fires Phaser.Data.Events#CHANGE_DATA_KEY * @since 3.23.0 * * @param {string} key - The key to change the value for. * @param {number} [amount=1] - The amount to increase the given key by. Pass a negative value to decrease the key. * * @return {this} This Data Manager instance. */ inc: function (key, amount) { if (this._frozen) { return this; } if (amount === undefined) { amount = 1; } var value = this.get(key); if (value === undefined) { value = 0; } this.set(key, (value + amount)); return this; }, /** * Toggle a boolean value for the given key. If the key doesn't already exist in the Data Manager then it is toggled from false. * * When the value is first set, a `setdata` event is emitted. * * @method Phaser.Data.DataManager#toggle * @fires Phaser.Data.Events#SET_DATA * @fires Phaser.Data.Events#CHANGE_DATA * @fires Phaser.Data.Events#CHANGE_DATA_KEY * @since 3.23.0 * * @param {string} key - The key to toggle the value for. * * @return {this} This Data Manager instance. */ toggle: function (key) { if (this._frozen) { return this; } this.set(key, !this.get(key)); return this; }, /** * Internal value setter, called automatically by the `set` method. * * @method Phaser.Data.DataManager#setValue * @fires Phaser.Data.Events#SET_DATA * @fires Phaser.Data.Events#CHANGE_DATA * @fires Phaser.Data.Events#CHANGE_DATA_KEY * @private * @since 3.10.0 * * @param {string} key - The key to set the value for. * @param {*} data - The value to set. * * @return {this} This Data Manager instance. */ setValue: function (key, data) { if (this._frozen) { return this; } if (this.has(key)) { // Hit the key getter, which will in turn emit the events. this.values[key] = data; } else { var _this = this; var list = this.list; var events = this.events; var parent = this.parent; Object.defineProperty(this.values, key, { enumerable: true, configurable: true, get: function () { return list[key]; }, set: function (value) { if (!_this._frozen) { var previousValue = list[key]; list[key] = value; events.emit(Events.CHANGE_DATA, parent, key, value, previousValue); events.emit(Events.CHANGE_DATA_KEY + key, parent, value, previousValue); } } }); list[key] = data; events.emit(Events.SET_DATA, parent, key, data); } return this; }, /** * Passes all data entries to the given callback. * * @method Phaser.Data.DataManager#each * @since 3.0.0 * * @param {DataEachCallback} callback - The function to call. * @param {*} [context] - Value to use as `this` when executing callback. * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data. * * @return {this} This Data Manager instance. */ each: function (callback, context) { 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(context, args); } return this; }, /** * Merge the given object of key value pairs into this DataManager. * * Any newly created values will emit a `setdata` event. Any updated values (see the `overwrite` argument) * will emit a `changedata` event. * * @method Phaser.Data.DataManager#merge * @fires Phaser.Data.Events#SET_DATA * @fires Phaser.Data.Events#CHANGE_DATA * @fires Phaser.Data.Events#CHANGE_DATA_KEY * @since 3.0.0 * * @param {Object.} data - The data to merge. * @param {boolean} [overwrite=true] - Whether to overwrite existing data. Defaults to true. * * @return {this} This Data Manager instance. */ 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.setValue(key, data[key]); } } return this; }, /** * Remove the value for the given key. * * If the key is found in this Data Manager it is removed from the internal lists and a * `removedata` event is emitted. * * You can also pass in an array of keys, in which case all keys in the array will be removed: * * ```javascript * this.data.remove([ 'gold', 'armor', 'health' ]); * ``` * * @method Phaser.Data.DataManager#remove * @fires Phaser.Data.Events#REMOVE_DATA * @since 3.0.0 * * @param {(string|string[])} key - The key to remove, or an array of keys to remove. * * @return {this} This Data Manager instance. */ remove: function (key) { if (this._frozen) { return this; } if (Array.isArray(key)) { for (var i = 0; i < key.length; i++) { this.removeValue(key[i]); } } else { return this.removeValue(key); } return this; }, /** * Internal value remover, called automatically by the `remove` method. * * @method Phaser.Data.DataManager#removeValue * @private * @fires Phaser.Data.Events#REMOVE_DATA * @since 3.10.0 * * @param {string} key - The key to set the value for. * * @return {this} This Data Manager instance. */ removeValue: function (key) { if (this.has(key)) { var data = this.list[key]; delete this.list[key]; delete this.values[key]; this.events.emit(Events.REMOVE_DATA, this.parent, key, data); } return this; }, /** * Retrieves the data associated with the given 'key', deletes it from this Data Manager, then returns it. * * @method Phaser.Data.DataManager#pop * @fires Phaser.Data.Events#REMOVE_DATA * @since 3.0.0 * * @param {string} key - The key of the value to retrieve and delete. * * @return {*} The value of the given key. */ pop: function (key) { var data = undefined; if (!this._frozen && this.has(key)) { data = this.list[key]; delete this.list[key]; delete this.values[key]; this.events.emit(Events.REMOVE_DATA, this.parent, key, data); } return data; }, /** * Determines whether the given key is set in this Data Manager. * * Please note that the keys are case-sensitive and must be valid JavaScript Object property strings. * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. * * @method Phaser.Data.DataManager#has * @since 3.0.0 * * @param {string} key - The key to check. * * @return {boolean} Returns `true` if the key exists, otherwise `false`. */ has: function (key) { return this.list.hasOwnProperty(key); }, /** * Freeze or unfreeze this Data Manager. A frozen Data Manager will block all attempts * to create new values or update existing ones. * * @method Phaser.Data.DataManager#setFreeze * @since 3.0.0 * * @param {boolean} value - Whether to freeze or unfreeze the Data Manager. * * @return {this} This Data Manager instance. */ setFreeze: function (value) { this._frozen = value; return this; }, /** * Delete all data in this Data Manager and unfreeze it. * * @method Phaser.Data.DataManager#reset * @since 3.0.0 * * @return {this} This Data Manager instance. */ reset: function () { for (var key in this.list) { delete this.list[key]; delete this.values[key]; } this._frozen = false; return this; }, /** * Destroy this data manager. * * @method Phaser.Data.DataManager#destroy * @since 3.0.0 */ destroy: function () { this.reset(); this.events.off(Events.CHANGE_DATA); this.events.off(Events.SET_DATA); this.events.off(Events.REMOVE_DATA); this.parent = null; }, /** * Gets or sets the frozen state of this Data Manager. * A frozen Data Manager will block all attempts to create new values or update existing ones. * * @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 Manager. * * @name Phaser.Data.DataManager#count * @type {number} * @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; /***/ }), /***/ 63646: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Class = __webpack_require__(83419); var DataManager = __webpack_require__(45893); var PluginCache = __webpack_require__(37277); var SceneEvents = __webpack_require__(44594); /** * @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 - A reference to the Scene that this DataManager belongs to. */ var DataManagerPlugin = new Class({ Extends: DataManager, initialize: function DataManagerPlugin (scene) { DataManager.call(this, scene, scene.sys.events); /** * A reference to the Scene that this DataManager belongs to. * * @name Phaser.Data.DataManagerPlugin#scene * @type {Phaser.Scene} * @since 3.0.0 */ this.scene = scene; /** * A reference to the Scene's Systems. * * @name Phaser.Data.DataManagerPlugin#systems * @type {Phaser.Scenes.Systems} * @since 3.0.0 */ this.systems = scene.sys; scene.sys.events.once(SceneEvents.BOOT, this.boot, this); scene.sys.events.on(SceneEvents.START, this.start, this); }, /** * This method is called automatically, only once, when the Scene is first created. * Do not invoke it directly. * * @method Phaser.Data.DataManagerPlugin#boot * @private * @since 3.5.1 */ boot: function () { this.events = this.systems.events; this.events.once(SceneEvents.DESTROY, this.destroy, this); }, /** * This method is called automatically by the Scene when it is starting up. * It is responsible for creating local systems, properties and listening for Scene events. * Do not invoke it directly. * * @method Phaser.Data.DataManagerPlugin#start * @private * @since 3.5.0 */ start: function () { this.events.once(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** * The Scene that owns this plugin is shutting down. * We need to kill and reset all internal properties as well as stop listening to Scene events. * * @method Phaser.Data.DataManagerPlugin#shutdown * @private * @since 3.5.0 */ shutdown: function () { this.systems.events.off(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** * The Scene that owns this plugin is being destroyed. * We need to shutdown and then kill off all external references. * * @method Phaser.Data.DataManagerPlugin#destroy * @since 3.5.0 */ destroy: function () { DataManager.prototype.destroy.call(this); this.events.off(SceneEvents.START, this.start, this); this.scene = null; this.systems = null; } }); PluginCache.register('DataManagerPlugin', DataManagerPlugin, 'data'); module.exports = DataManagerPlugin; /***/ }), /***/ 10700: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Change Data Event. * * This event is dispatched by a Data Manager when an item in the data store is changed. * * Game Objects with data enabled have an instance of a Data Manager under the `data` property. So, to listen for * a change data event from a Game Object you would use: `sprite.on('changedata', listener)`. * * This event is dispatched for all items that change in the Data Manager. * To listen for the change of a specific item, use the `CHANGE_DATA_KEY_EVENT` event. * * @event Phaser.Data.Events#CHANGE_DATA * @type {string} * @since 3.0.0 * * @param {any} parent - A reference to the object that the Data Manager responsible for this event belongs to. * @param {string} key - The unique key of the data item within the Data Manager. * @param {any} value - The new value of the item in the Data Manager. * @param {any} previousValue - The previous value of the item in the Data Manager. */ module.exports = 'changedata'; /***/ }), /***/ 93608: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Change Data Key Event. * * This event is dispatched by a Data Manager when an item in the data store is changed. * * Game Objects with data enabled have an instance of a Data Manager under the `data` property. So, to listen for * the change of a specific data item from a Game Object you would use: `sprite.on('changedata-key', listener)`, * where `key` is the unique string key of the data item. For example, if you have a data item stored called `gold` * then you can listen for `sprite.on('changedata-gold')`. * * @event Phaser.Data.Events#CHANGE_DATA_KEY * @type {string} * @since 3.16.1 * * @param {any} parent - A reference to the object that owns the instance of the Data Manager responsible for this event. * @param {any} value - The item that was updated in the Data Manager. This can be of any data type, i.e. a string, boolean, number, object or instance. * @param {any} previousValue - The previous item that was updated in the Data Manager. This can be of any data type, i.e. a string, boolean, number, object or instance. */ module.exports = 'changedata-'; /***/ }), /***/ 60883: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Data Manager Destroy Event. * * The Data Manager will listen for the destroy event from its parent, and then close itself down. * * @event Phaser.Data.Events#DESTROY * @type {string} * @since 3.50.0 */ module.exports = 'destroy'; /***/ }), /***/ 69780: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Remove Data Event. * * This event is dispatched by a Data Manager when an item is removed from it. * * Game Objects with data enabled have an instance of a Data Manager under the `data` property. So, to listen for * the removal of a data item on a Game Object you would use: `sprite.on('removedata', listener)`. * * @event Phaser.Data.Events#REMOVE_DATA * @type {string} * @since 3.0.0 * * @param {any} parent - A reference to the object that owns the instance of the Data Manager responsible for this event. * @param {string} key - The unique key of the data item within the Data Manager. * @param {any} data - The item that was removed from the Data Manager. This can be of any data type, i.e. a string, boolean, number, object or instance. */ module.exports = 'removedata'; /***/ }), /***/ 22166: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * The Set Data Event. * * This event is dispatched by a Data Manager when a new item is added to the data store. * * Game Objects with data enabled have an instance of a Data Manager under the `data` property. So, to listen for * the addition of a new data item on a Game Object you would use: `sprite.on('setdata', listener)`. * * @event Phaser.Data.Events#SET_DATA * @type {string} * @since 3.0.0 * * @param {any} parent - A reference to the object that owns the instance of the Data Manager responsible for this event. * @param {string} key - The unique key of the data item within the Data Manager. * @param {any} data - The item that was added to the Data Manager. This can be of any data type, i.e. a string, boolean, number, object or instance. */ module.exports = 'setdata'; /***/ }), /***/ 24882: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Data.Events */ module.exports = { CHANGE_DATA: __webpack_require__(10700), CHANGE_DATA_KEY: __webpack_require__(93608), DESTROY: __webpack_require__(60883), REMOVE_DATA: __webpack_require__(69780), SET_DATA: __webpack_require__(22166) }; /***/ }), /***/ 44965: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Data */ module.exports = { DataManager: __webpack_require__(45893), DataManagerPlugin: __webpack_require__(63646), Events: __webpack_require__(24882) }; /***/ }), /***/ 7098: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Browser = __webpack_require__(84148); /** * 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. * * @typedef {object} Phaser.Device.Audio * @since 3.0.0 * * @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} aac - Can this device can play aac files. * @property {boolean} flac - Can this device can play flac 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 = { flac: false, aac: false, audioData: false, dolby: false, m4a: false, mp3: false, ogg: false, opus: false, wav: false, webAudio: false, webm: false }; function init () { if (typeof importScripts === 'function') { return Audio; } Audio.audioData = !!(window['Audio']); Audio.webAudio = !!(window['AudioContext'] || window['webkitAudioContext']); var audioElement = document.createElement('audio'); var result = !!audioElement.canPlayType; try { if (result) { var CanPlay = function (type1, type2) { var canPlayType1 = audioElement.canPlayType('audio/' + type1).replace(/^no$/, ''); if (type2) { return Boolean(canPlayType1 || audioElement.canPlayType('audio/' + type2).replace(/^no$/, '')); } else { return Boolean(canPlayType1); } }; // wav Mimetypes accepted: // developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements Audio.ogg = CanPlay('ogg; codecs="vorbis"'); Audio.opus = CanPlay('ogg; codecs="opus"', 'opus'); Audio.mp3 = CanPlay('mpeg'); Audio.wav = CanPlay('wav'); Audio.m4a = CanPlay('x-m4a'); Audio.aac = CanPlay('aac'); Audio.flac = CanPlay('flac', 'x-flac'); Audio.webm = CanPlay('webm; codecs="vorbis"'); 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(); /***/ }), /***/ 84148: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var OS = __webpack_require__(25892); /** * 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. * * @typedef {object} Phaser.Device.Browser * @since 3.0.0 * * @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, es2019: false }; function init () { var ua = navigator.userAgent; if ((/Edg\/\d+/).test(ua)) { Browser.edge = true; Browser.es2019 = true; } else if ((/OPR/).test(ua)) { Browser.opera = true; Browser.es2019 = true; } else if ((/Chrome\/(\d+)/).test(ua) && !OS.windowsPhone) { Browser.chrome = true; Browser.chromeVersion = parseInt(RegExp.$1, 10); Browser.es2019 = (Browser.chromeVersion > 69); } else if ((/Firefox\D+(\d+)/).test(ua)) { Browser.firefox = true; Browser.firefoxVersion = parseInt(RegExp.$1, 10); Browser.es2019 = (Browser.firefoxVersion > 10); } else if ((/AppleWebKit\/(?!.*CriOS)/).test(ua) && OS.iOS) { Browser.mobileSafari = true; Browser.es2019 = true; } else if ((/MSIE (\d+\.\d+);/).test(ua)) { Browser.ie = true; Browser.ieVersion = parseInt(RegExp.$1, 10); } else if ((/Version\/(\d+\.\d+(\.\d+)?) Safari/).test(ua) && !OS.windowsPhone) { Browser.safari = true; Browser.safariVersion = parseInt(RegExp.$1, 10); Browser.es2019 = (Browser.safariVersion > 10); } 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(); /***/ }), /***/ 89289: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var CanvasPool = __webpack_require__(27919); /** * 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. * * @typedef {object} Phaser.Device.CanvasFeatures * @since 3.0.0 * * @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.create2D(yellow, 6); var context = canvas.getContext('2d', { willReadFrequently: true }); 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.create2D(this, 2); var context = canvas.getContext('2d', { willReadFrequently: true }); 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); var result = (s2.data[0] === s1.data[0] && s2.data[1] === s1.data[1] && s2.data[2] === s1.data[2] && s2.data[3] === s1.data[3]); CanvasPool.remove(this); // Compare and return return result; } function init () { if (typeof importScripts !== 'function' && document !== undefined) { CanvasFeatures.supportNewBlendModes = checkBlendMode(); CanvasFeatures.supportInverseAlpha = checkInverseAlpha(); } return CanvasFeatures; } module.exports = init(); /***/ }), /***/ 89357: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var OS = __webpack_require__(25892); var Browser = __webpack_require__(84148); var CanvasPool = __webpack_require__(27919); /** * 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. * * @typedef {object} Phaser.Device.Features * @since 3.0.0 * * @property {boolean} canvas - Is canvas available? * @property {?boolean} canvasBitBltShift - True if canvas supports a 'copy' bitblt onto itself when the source and destination regions overlap. * @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} stableSort - Is Array.sort stable? * @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, stableSort: 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 () { if (typeof importScripts === 'function') { return Features; } Features.canvas = !!window['CanvasRenderingContext2D']; 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); var ctx = canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); var canvas2D = CanvasPool.create2D(this); var ctx2D = canvas2D.getContext('2d', { willReadFrequently: true }); // 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(); /***/ }), /***/ 91639: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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. * * @typedef {object} Phaser.Device.Fullscreen * @since 3.0.0 * * @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. * * @ignore */ function init () { if (typeof importScripts === 'function') { return Fullscreen; } var i; var suffix1 = 'Fullscreen'; var suffix2 = 'FullScreen'; var fs = [ 'request' + suffix1, 'request' + suffix2, 'webkitRequest' + suffix1, 'webkitRequest' + suffix2, 'msRequest' + suffix1, 'msRequest' + suffix2, 'mozRequest' + suffix2, 'mozRequest' + suffix1 ]; for (i = 0; i < fs.length; i++) { if (document.documentElement[fs[i]]) { Fullscreen.available = true; Fullscreen.request = fs[i]; break; } } var cfs = [ 'cancel' + suffix2, 'exit' + suffix1, 'webkitCancel' + suffix2, 'webkitExit' + suffix1, 'msCancel' + suffix2, 'msExit' + suffix1, 'mozCancel' + suffix2, 'mozExit' + suffix1 ]; if (Fullscreen.available) { for (i = 0; i < cfs.length; i++) { if (document[cfs[i]]) { Fullscreen.cancel = cfs[i]; break; } } } // Keyboard Input? // Safari 5.1 says it supports fullscreen keyboard, but is lying. if (window['Element'] && Element['ALLOW_KEYBOARD_INPUT'] && !(/ Version\/5\.1(?:\.\d+)? Safari\//).test(navigator.userAgent)) { Fullscreen.keyboard = true; } Object.defineProperty(Fullscreen, 'active', { get: function () { return !!(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement); } }); return Fullscreen; } module.exports = init(); /***/ }), /***/ 31784: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Browser = __webpack_require__(84148); /** * 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. * * @typedef {object} Phaser.Device.Input * @since 3.0.0 * * @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 (typeof importScripts === 'function') { return Input; } 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; } // 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(); /***/ }), /***/ 25892: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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. * * @typedef {object} Phaser.Device.OS * @since 3.0.0 * * @property {boolean} android - Is running on android? * @property {boolean} chromeOS - Is running on chromeOS? * @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, 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 () { if (typeof importScripts === 'function') { return OS; } var ua = navigator.userAgent; if ((/Windows/).test(ua)) { OS.windows = true; } else if ((/Mac OS/).test(ua) && !((/like Mac OS/).test(ua))) { // Because iOS 13 identifies as Mac OS: if (navigator.maxTouchPoints && navigator.maxTouchPoints > 2) { OS.iOS = true; OS.iPad = true; (navigator.appVersion).match(/Version\/(\d+)/); OS.iOSVersion = parseInt(RegExp.$1, 10); } else { OS.macOS = true; } } else if ((/Android/).test(ua)) { OS.android = true; } else if ((/Linux/).test(ua)) { OS.linux = true; } else if ((/iP[ao]d|iPhone/i).test(ua)) { OS.iOS = true; (navigator.appVersion).match(/OS (\d+)/); OS.iOSVersion = parseInt(RegExp.$1, 10); OS.iPhone = ua.toLowerCase().indexOf('iphone') !== -1; OS.iPad = ua.toLowerCase().indexOf('ipad') !== -1; } 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 (typeof importScripts !== 'function') { if (window.cordova !== undefined) { OS.cordova = true; } if (window.ejecta !== undefined) { OS.ejecta = true; } } if (typeof process !== 'undefined' && process.versions && process.versions.node) { OS.node = true; } if (OS.node && typeof process.versions === 'object') { OS.nodeWebkit = !!process.versions['node-webkit']; OS.electron = !!process.versions.electron; } if ((/Crosswalk/).test(ua)) { OS.crosswalk = true; } OS.pixelRatio = window['devicePixelRatio'] || 1; return OS; } module.exports = init(); /***/ }), /***/ 43267: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetFastValue = __webpack_require__(95540); /** * 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. * * In Phaser 3.20 the properties were renamed to drop the 'Video' suffix. * * @typedef {object} Phaser.Device.Video * @since 3.0.0 * * @property {boolean} h264 - Can this device play h264 mp4 video files? * @property {boolean} hls - Can this device play hls video files? * @property {boolean} mp4 - Can this device play h264 mp4 video files? * @property {boolean} m4v - Can this device play m4v (typically mp4) video files? * @property {boolean} ogg - Can this device play ogg video files? * @property {boolean} vp9 - Can this device play vp9 video files? * @property {boolean} webm - Can this device play webm video files? * @property {function} getVideoURL - Returns the first video URL that can be played by this browser. */ var Video = { h264: false, hls: false, mp4: false, m4v: false, ogg: false, vp9: false, webm: false, hasRequestVideoFrame: false }; function init () { if (typeof importScripts === 'function') { return Video; } var videoElement = document.createElement('video'); var result = !!videoElement.canPlayType; var no = /^no$/; try { if (result) { if (videoElement.canPlayType('video/ogg; codecs="theora"').replace(no, '')) { Video.ogg = 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.h264 = true; Video.mp4 = true; } if (videoElement.canPlayType('video/x-m4v').replace(no, '')) { Video.m4v = true; } if (videoElement.canPlayType('video/webm; codecs="vp8, vorbis"').replace(no, '')) { Video.webm = true; } if (videoElement.canPlayType('video/webm; codecs="vp9"').replace(no, '')) { Video.vp9 = true; } if (videoElement.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(no, '')) { Video.hls = true; } } } catch (e) { // Nothing to do } if (videoElement.parentNode) { videoElement.parentNode.removeChild(videoElement); } Video.getVideoURL = function (urls) { if (!Array.isArray(urls)) { urls = [ urls ]; } for (var i = 0; i < urls.length; i++) { var url = GetFastValue(urls[i], 'url', urls[i]); if (url.indexOf('blob:') === 0) { return { url: url, type: '' }; } var videoType; if (url.indexOf('data:') === 0) { videoType = url.split(',')[0].match(/\/(.*?);/); } else { videoType = url.match(/\.([a-zA-Z0-9]+)($|\?)/); } videoType = GetFastValue(urls[i], 'type', (videoType) ? videoType[1] : '').toLowerCase(); if (Video[videoType]) { return { url: url, type: videoType }; } } return null; }; return Video; } module.exports = init(); /***/ }), /***/ 82264: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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__(25892), browser: __webpack_require__(84148), features: __webpack_require__(89357), input: __webpack_require__(31784), audio: __webpack_require__(7098), video: __webpack_require__(43267), fullscreen: __webpack_require__(91639), canvasFeatures: __webpack_require__(89289) }; /***/ }), /***/ 89422: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Class = __webpack_require__(83419); var tempMatrix = new Float32Array(20); /** * @classdesc * The ColorMatrix class creates a 5x4 matrix that can be used in shaders and graphics * operations. It provides methods required to modify the color values, such as adjusting * the brightness, setting a sepia tone, hue rotation and more. * * Use the method `getData` to return a Float32Array containing the current color values. * * @class ColorMatrix * @memberof Phaser.Display * @constructor * @since 3.50.0 */ var ColorMatrix = new Class({ initialize: function ColorMatrix () { /** * Internal ColorMatrix array. * * @name Phaser.Display.ColorMatrix#_matrix * @type {Float32Array} * @private * @since 3.50.0 */ this._matrix = new Float32Array(20); /** * The value that determines how much of the original color is used * when mixing the colors. A value between 0 (all original) and 1 (all final) * * @name Phaser.Display.ColorMatrix#alpha * @type {number} * @since 3.50.0 */ this.alpha = 1; /** * Is the ColorMatrix array dirty? * * @name Phaser.Display.ColorMatrix#_dirty * @type {boolean} * @private * @since 3.50.0 */ this._dirty = true; /** * The matrix data as a Float32Array. * * Returned by the `getData` method. * * @name Phaser.Display.ColorMatrix#data * @type {Float32Array} * @private * @since 3.50.0 */ this._data = new Float32Array(20); this.reset(); }, /** * Sets this ColorMatrix from the given array of color values. * * @method Phaser.Display.ColorMatrix#set * @since 3.50.0 * * @param {(number[]|Float32Array)} value - The ColorMatrix values to set. Must have 20 elements. * * @return {this} This ColorMatrix instance. */ set: function (value) { this._matrix.set(value); this._dirty = true; return this; }, /** * Resets the ColorMatrix to default values and also resets * the `alpha` property back to 1. * * @method Phaser.Display.ColorMatrix#reset * @since 3.50.0 * * @return {this} This ColorMatrix instance. */ reset: function () { var m = this._matrix; m.fill(0); m[0] = 1; m[6] = 1; m[12] = 1; m[18] = 1; this.alpha = 1; this._dirty = true; return this; }, /** * Gets the ColorMatrix as a Float32Array. * * Can be used directly as a 1fv shader uniform value. * * @method Phaser.Display.ColorMatrix#getData * @since 3.50.0 * * @return {Float32Array} The ColorMatrix as a Float32Array. */ getData: function () { var data = this._data; if (this._dirty) { data.set(this._matrix); data[4] /= 255; data[9] /= 255; data[14] /= 255; data[19] /= 255; this._dirty = false; } return data; }, /** * Changes the brightness of this ColorMatrix by the given amount. * * @method Phaser.Display.ColorMatrix#brightness * @since 3.50.0 * * @param {number} [value=0] - The amount of brightness to apply to this ColorMatrix. Between 0 (black) and 1. * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? * * @return {this} This ColorMatrix instance. */ brightness: function (value, multiply) { if (value === undefined) { value = 0; } if (multiply === undefined) { multiply = false; } var b = value; return this.multiply([ b, 0, 0, 0, 0, 0, b, 0, 0, 0, 0, 0, b, 0, 0, 0, 0, 0, 1, 0 ], multiply); }, /** * Changes the saturation of this ColorMatrix by the given amount. * * @method Phaser.Display.ColorMatrix#saturate * @since 3.50.0 * * @param {number} [value=0] - The amount of saturation to apply to this ColorMatrix. * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? * * @return {this} This ColorMatrix instance. */ saturate: function (value, multiply) { if (value === undefined) { value = 0; } if (multiply === undefined) { multiply = false; } var x = (value * 2 / 3) + 1; var y = ((x - 1) * -0.5); return this.multiply([ x, y, y, 0, 0, y, x, y, 0, 0, y, y, x, 0, 0, 0, 0, 0, 1, 0 ], multiply); }, /** * Desaturates this ColorMatrix (removes color from it). * * @method Phaser.Display.ColorMatrix#saturation * @since 3.50.0 * * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? * * @return {this} This ColorMatrix instance. */ desaturate: function (multiply) { if (multiply === undefined) { multiply = false; } return this.saturate(-1, multiply); }, /** * Rotates the hues of this ColorMatrix by the value given. * * @method Phaser.Display.ColorMatrix#hue * @since 3.50.0 * * @param {number} [rotation=0] - The amount of hue rotation to apply to this ColorMatrix, in degrees. * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? * * @return {this} This ColorMatrix instance. */ hue: function (rotation, multiply) { if (rotation === undefined) { rotation = 0; } if (multiply === undefined) { multiply = false; } rotation = rotation / 180 * Math.PI; var cos = Math.cos(rotation); var sin = Math.sin(rotation); var lumR = 0.213; var lumG = 0.715; var lumB = 0.072; return this.multiply([ lumR + cos * (1 - lumR) + sin * (-lumR),lumG + cos * (-lumG) + sin * (-lumG),lumB + cos * (-lumB) + sin * (1 - lumB), 0, 0, lumR + cos * (-lumR) + sin * (0.143),lumG + cos * (1 - lumG) + sin * (0.140),lumB + cos * (-lumB) + sin * (-0.283), 0, 0, lumR + cos * (-lumR) + sin * (-(1 - lumR)),lumG + cos * (-lumG) + sin * (lumG),lumB + cos * (1 - lumB) + sin * (lumB), 0, 0, 0, 0, 0, 1, 0 ], multiply); }, /** * Sets this ColorMatrix to be grayscale. * * @method Phaser.Display.ColorMatrix#grayscale * @since 3.50.0 * * @param {number} [value=1] - The grayscale scale (0 is black). * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? * * @return {this} This ColorMatrix instance. */ grayscale: function (value, multiply) { if (value === undefined) { value = 1; } if (multiply === undefined) { multiply = false; } return this.saturate(-value, multiply); }, /** * Sets this ColorMatrix to be black and white. * * @method Phaser.Display.ColorMatrix#blackWhite * @since 3.50.0 * * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? * * @return {this} This ColorMatrix instance. */ blackWhite: function (multiply) { if (multiply === undefined) { multiply = false; } return this.multiply(ColorMatrix.BLACK_WHITE, multiply); }, /** * Change the contrast of this ColorMatrix by the amount given. * * @method Phaser.Display.ColorMatrix#contrast * @since 3.50.0 * * @param {number} [value=0] - The amount of contrast to apply to this ColorMatrix. * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? * * @return {this} This ColorMatrix instance. */ contrast: function (value, multiply) { if (value === undefined) { value = 0; } if (multiply === undefined) { multiply = false; } var v = value + 1; var o = -0.5 * (v - 1); return this.multiply([ v, 0, 0, 0, o, 0, v, 0, 0, o, 0, 0, v, 0, o, 0, 0, 0, 1, 0 ], multiply); }, /** * Converts this ColorMatrix to have negative values. * * @method Phaser.Display.ColorMatrix#negative * @since 3.50.0 * * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? * * @return {this} This ColorMatrix instance. */ negative: function (multiply) { if (multiply === undefined) { multiply = false; } return this.multiply(ColorMatrix.NEGATIVE, multiply); }, /** * Apply a desaturated luminance to this ColorMatrix. * * @method Phaser.Display.ColorMatrix#desaturateLuminance * @since 3.50.0 * * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? * * @return {this} This ColorMatrix instance. */ desaturateLuminance: function (multiply) { if (multiply === undefined) { multiply = false; } return this.multiply(ColorMatrix.DESATURATE_LUMINANCE, multiply); }, /** * Applies a sepia tone to this ColorMatrix. * * @method Phaser.Display.ColorMatrix#sepia * @since 3.50.0 * * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? * * @return {this} This ColorMatrix instance. */ sepia: function (multiply) { if (multiply === undefined) { multiply = false; } return this.multiply(ColorMatrix.SEPIA, multiply); }, /** * Applies a night vision tone to this ColorMatrix. * * @method Phaser.Display.ColorMatrix#night * @since 3.50.0 * * @param {number} [intensity=0.1] - The intensity of this effect. * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? * * @return {this} This ColorMatrix instance. */ night: function (intensity, multiply) { if (intensity === undefined) { intensity = 0.1; } if (multiply === undefined) { multiply = false; } return this.multiply([ intensity * (-2.0), -intensity, 0, 0, 0, -intensity, 0, intensity, 0, 0, 0, intensity, intensity * 2.0, 0, 0, 0, 0, 0, 1, 0 ], multiply); }, /** * Applies a trippy color tone to this ColorMatrix. * * @method Phaser.Display.ColorMatrix#lsd * @since 3.50.0 * * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? * * @return {this} This ColorMatrix instance. */ lsd: function (multiply) { if (multiply === undefined) { multiply = false; } return this.multiply(ColorMatrix.LSD, multiply); }, /** * Applies a brown tone to this ColorMatrix. * * @method Phaser.Display.ColorMatrix#brown * @since 3.50.0 * * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? * * @return {this} This ColorMatrix instance. */ brown: function (multiply) { if (multiply === undefined) { multiply = false; } return this.multiply(ColorMatrix.BROWN, multiply); }, /** * Applies a vintage pinhole color effect to this ColorMatrix. * * @method Phaser.Display.ColorMatrix#vintagePinhole * @since 3.50.0 * * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? * * @return {this} This ColorMatrix instance. */ vintagePinhole: function (multiply) { if (multiply === undefined) { multiply = false; } return this.multiply(ColorMatrix.VINTAGE, multiply); }, /** * Applies a kodachrome color effect to this ColorMatrix. * * @method Phaser.Display.ColorMatrix#kodachrome * @since 3.50.0 * * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? * * @return {this} This ColorMatrix instance. */ kodachrome: function (multiply) { if (multiply === undefined) { multiply = false; } return this.multiply(ColorMatrix.KODACHROME, multiply); }, /** * Applies a technicolor color effect to this ColorMatrix. * * @method Phaser.Display.ColorMatrix#technicolor * @since 3.50.0 * * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? * * @return {this} This ColorMatrix instance. */ technicolor: function (multiply) { if (multiply === undefined) { multiply = false; } return this.multiply(ColorMatrix.TECHNICOLOR, multiply); }, /** * Applies a polaroid color effect to this ColorMatrix. * * @method Phaser.Display.ColorMatrix#polaroid * @since 3.50.0 * * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? * * @return {this} This ColorMatrix instance. */ polaroid: function (multiply) { if (multiply === undefined) { multiply = false; } return this.multiply(ColorMatrix.POLAROID, multiply); }, /** * Shifts the values of this ColorMatrix into BGR order. * * @method Phaser.Display.ColorMatrix#shiftToBGR * @since 3.50.0 * * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? * * @return {this} This ColorMatrix instance. */ shiftToBGR: function (multiply) { if (multiply === undefined) { multiply = false; } return this.multiply(ColorMatrix.SHIFT_BGR, multiply); }, /** * Multiplies the two given matrices. * * @method Phaser.Display.ColorMatrix#multiply * @since 3.50.0 * * @param {number[]} a - The 5x4 array to multiply with ColorMatrix._matrix. * @param {boolean} [multiply=false] - Multiply the resulting ColorMatrix (`true`), or set it (`false`) ? * * @return {this} This ColorMatrix instance. */ multiply: function (a, multiply) { if (multiply === undefined) { multiply = false; } // Duplicate _matrix into c if (!multiply) { this.reset(); } var m = this._matrix; var c = tempMatrix; // copy _matrix to tempMatrox c.set(m); m.set([ // R (c[0] * a[0]) + (c[1] * a[5]) + (c[2] * a[10]) + (c[3] * a[15]), (c[0] * a[1]) + (c[1] * a[6]) + (c[2] * a[11]) + (c[3] * a[16]), (c[0] * a[2]) + (c[1] * a[7]) + (c[2] * a[12]) + (c[3] * a[17]), (c[0] * a[3]) + (c[1] * a[8]) + (c[2] * a[13]) + (c[3] * a[18]), (c[0] * a[4]) + (c[1] * a[9]) + (c[2] * a[14]) + (c[3] * a[19]) + c[4], // G (c[5] * a[0]) + (c[6] * a[5]) + (c[7] * a[10]) + (c[8] * a[15]), (c[5] * a[1]) + (c[6] * a[6]) + (c[7] * a[11]) + (c[8] * a[16]), (c[5] * a[2]) + (c[6] * a[7]) + (c[7] * a[12]) + (c[8] * a[17]), (c[5] * a[3]) + (c[6] * a[8]) + (c[7] * a[13]) + (c[8] * a[18]), (c[5] * a[4]) + (c[6] * a[9]) + (c[7] * a[14]) + (c[8] * a[19]) + c[9], // B (c[10] * a[0]) + (c[11] * a[5]) + (c[12] * a[10]) + (c[13] * a[15]), (c[10] * a[1]) + (c[11] * a[6]) + (c[12] * a[11]) + (c[13] * a[16]), (c[10] * a[2]) + (c[11] * a[7]) + (c[12] * a[12]) + (c[13] * a[17]), (c[10] * a[3]) + (c[11] * a[8]) + (c[12] * a[13]) + (c[13] * a[18]), (c[10] * a[4]) + (c[11] * a[9]) + (c[12] * a[14]) + (c[13] * a[19]) + c[14], // A (c[15] * a[0]) + (c[16] * a[5]) + (c[17] * a[10]) + (c[18] * a[15]), (c[15] * a[1]) + (c[16] * a[6]) + (c[17] * a[11]) + (c[18] * a[16]), (c[15] * a[2]) + (c[16] * a[7]) + (c[17] * a[12]) + (c[18] * a[17]), (c[15] * a[3]) + (c[16] * a[8]) + (c[17] * a[13]) + (c[18] * a[18]), (c[15] * a[4]) + (c[16] * a[9]) + (c[17] * a[14]) + (c[18] * a[19]) + c[19] ]); this._dirty = true; return this; } }); /** * A constant array used by the ColorMatrix class for black_white operations. * * @name Phaser.Display.ColorMatrix.BLACK_WHITE * @const * @type {number[]} * @since 3.60.0 */ ColorMatrix.BLACK_WHITE = [ 0.3, 0.6, 0.1, 0, 0, 0.3, 0.6, 0.1, 0, 0, 0.3, 0.6, 0.1, 0, 0, 0, 0, 0, 1, 0 ]; /** * A constant array used by the ColorMatrix class for negative operations. * * @name Phaser.Display.ColorMatrix.NEGATIVE * @const * @type {number[]} * @since 3.60.0 */ ColorMatrix.NEGATIVE = [ -1, 0, 0, 1, 0, 0, -1, 0, 1, 0, 0, 0, -1, 1, 0, 0, 0, 0, 1, 0 ]; /** * A constant array used by the ColorMatrix class for desatured luminance operations. * * @name Phaser.Display.ColorMatrix.DESATURATE_LUMINANCE * @const * @type {number[]} * @since 3.60.0 */ ColorMatrix.DESATURATE_LUMINANCE = [ 0.2764723, 0.9297080, 0.0938197, 0, -37.1, 0.2764723, 0.9297080, 0.0938197, 0, -37.1, 0.2764723, 0.9297080, 0.0938197, 0, -37.1, 0, 0, 0, 1, 0 ]; /** * A constant array used by the ColorMatrix class for sepia operations. * * @name Phaser.Display.ColorMatrix.SEPIA * @const * @type {number[]} * @since 3.60.0 */ ColorMatrix.SEPIA = [ 0.393, 0.7689999, 0.18899999, 0, 0, 0.349, 0.6859999, 0.16799999, 0, 0, 0.272, 0.5339999, 0.13099999, 0, 0, 0, 0, 0, 1, 0 ]; /** * A constant array used by the ColorMatrix class for lsd operations. * * @name Phaser.Display.ColorMatrix.LSD * @const * @type {number[]} * @since 3.60.0 */ ColorMatrix.LSD = [ 2, -0.4, 0.5, 0, 0, -0.5, 2, -0.4, 0, 0, -0.4, -0.5, 3, 0, 0, 0, 0, 0, 1, 0 ]; /** * A constant array used by the ColorMatrix class for brown operations. * * @name Phaser.Display.ColorMatrix.BROWN * @const * @type {number[]} * @since 3.60.0 */ ColorMatrix.BROWN = [ 0.5997023498159715, 0.34553243048391263, -0.2708298674538042, 0, 47.43192855600873, -0.037703249837783157, 0.8609577587992641, 0.15059552388459913, 0, -36.96841498319127, 0.24113635128153335, -0.07441037908422492, 0.44972182064877153, 0, -7.562075277591283, 0, 0, 0, 1, 0 ]; /** * A constant array used by the ColorMatrix class for vintage pinhole operations. * * @name Phaser.Display.ColorMatrix.VINTAGE * @const * @type {number[]} * @since 3.60.0 */ ColorMatrix.VINTAGE = [ 0.6279345635605994, 0.3202183420819367, -0.03965408211312453, 0, 9.651285835294123, 0.02578397704808868, 0.6441188644374771, 0.03259127616149294, 0, 7.462829176470591, 0.0466055556782719, -0.0851232987247891, 0.5241648018700465, 0, 5.159190588235296, 0, 0, 0, 1, 0 ]; /** * A constant array used by the ColorMatrix class for kodachrome operations. * * @name Phaser.Display.ColorMatrix.KODACHROME * @const * @type {number[]} * @since 3.60.0 */ ColorMatrix.KODACHROME = [ 1.1285582396593525, -0.3967382283601348, -0.03992559172921793, 0, 63.72958762196502, -0.16404339962244616, 1.0835251566291304, -0.05498805115633132, 0, 24.732407896706203, -0.16786010706155763, -0.5603416277695248, 1.6014850761964943, 0, 35.62982807460946, 0, 0, 0, 1, 0 ]; /** * A constant array used by the ColorMatrix class for technicolor operations. * * @name Phaser.Display.ColorMatrix.TECHNICOLOR * @const * @type {number[]} * @since 3.60.0 */ ColorMatrix.TECHNICOLOR = [ 1.9125277891456083, -0.8545344976951645, -0.09155508482755585, 0, 11.793603434377337, -0.3087833385928097, 1.7658908555458428, -0.10601743074722245, 0, -70.35205161461398, -0.231103377548616, -0.7501899197440212, 1.847597816108189, 0, 30.950940869491138, 0, 0, 0, 1, 0 ]; /** * A constant array used by the ColorMatrix class for polaroid shift operations. * * @name Phaser.Display.ColorMatrix.POLAROID * @const * @type {number[]} * @since 3.60.0 */ ColorMatrix.POLAROID = [ 1.438, -0.062, -0.062, 0, 0, -0.122, 1.378, -0.122, 0, 0, -0.016, -0.016, 1.483, 0, 0, 0, 0, 0, 1, 0 ]; /** * A constant array used by the ColorMatrix class for shift BGR operations. * * @name Phaser.Display.ColorMatrix.SHIFT_BGR * @const * @type {number[]} * @since 3.60.0 */ ColorMatrix.SHIFT_BGR = [ 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]; module.exports = ColorMatrix; /***/ }), /***/ 51767: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Class = __webpack_require__(83419); var NOOP = __webpack_require__(29747); /** * @classdesc * The RGB class holds a single color value and allows for easy modification and reading of it, * with optional on-change callback notification and a dirty flag. * * @class RGB * @memberof Phaser.Display * @constructor * @since 3.50.0 * * @param {number} [red=0] - The red color value. A number between 0 and 1. * @param {number} [green=0] - The green color value. A number between 0 and 1. * @param {number} [blue=0] - The blue color value. A number between 0 and 1. */ var RGB = new Class({ initialize: function RGB (red, green, blue) { /** * Cached RGB values. * * @name Phaser.Display.RGB#_rgb * @type {number[]} * @private * @since 3.50.0 */ this._rgb = [ 0, 0, 0 ]; /** * This callback will be invoked each time one of the RGB color values change. * * The callback is sent the new color values as the parameters. * * @name Phaser.Display.RGB#onChangeCallback * @type {function} * @since 3.50.0 */ this.onChangeCallback = NOOP; /** * Is this color dirty? * * @name Phaser.Display.RGB#dirty * @type {boolean} * @since 3.50.0 */ this.dirty = false; this.set(red, green, blue); }, /** * Sets the red, green and blue values of this RGB object, flags it as being * dirty and then invokes the `onChangeCallback`, if set. * * @method Phaser.Display.RGB#set * @since 3.50.0 * * @param {number} [red=0] - The red color value. A number between 0 and 1. * @param {number} [green=0] - The green color value. A number between 0 and 1. * @param {number} [blue=0] - The blue color value. A number between 0 and 1. * * @return {this} This RGB instance. */ set: function (red, green, blue) { if (red === undefined) { red = 0; } if (green === undefined) { green = 0; } if (blue === undefined) { blue = 0; } this._rgb = [ red, green, blue ]; this.onChange(); return this; }, /** * Compares the given rgb parameters with those in this object and returns * a boolean `true` value if they are equal, otherwise it returns `false`. * * @method Phaser.Display.RGB#equals * @since 3.50.0 * * @param {number} red - The red value to compare with this object. * @param {number} green - The green value to compare with this object. * @param {number} blue - The blue value to compare with this object. * * @return {boolean} `true` if the given values match those in this object, otherwise `false`. */ equals: function (red, green, blue) { var rgb = this._rgb; return (rgb[0] === red && rgb[1] === green && rgb[2] === blue); }, /** * Internal on change handler. Sets this object as being dirty and * then invokes the `onChangeCallback`, if set, passing in the * new RGB values. * * @method Phaser.Display.RGB#onChange * @since 3.50.0 */ onChange: function () { this.dirty = true; var rgb = this._rgb; this.onChangeCallback.call(this, rgb[0], rgb[1], rgb[2]); }, /** * The red color value. Between 0 and 1. * * Changing this property will flag this RGB object as being dirty * and invoke the `onChangeCallback` , if set. * * @name Phaser.Display.RGB#r * @type {number} * @since 3.50.0 */ r: { get: function () { return this._rgb[0]; }, set: function (value) { this._rgb[0] = value; this.onChange(); } }, /** * The green color value. Between 0 and 1. * * Changing this property will flag this RGB object as being dirty * and invoke the `onChangeCallback` , if set. * * @name Phaser.Display.RGB#g * @type {number} * @since 3.50.0 */ g: { get: function () { return this._rgb[1]; }, set: function (value) { this._rgb[1] = value; this.onChange(); } }, /** * The blue color value. Between 0 and 1. * * Changing this property will flag this RGB object as being dirty * and invoke the `onChangeCallback` , if set. * * @name Phaser.Display.RGB#b * @type {number} * @since 3.50.0 */ b: { get: function () { return this._rgb[2]; }, set: function (value) { this._rgb[2] = value; this.onChange(); } }, /** * Nulls any external references this object contains. * * @method Phaser.Display.RGB#destroy * @since 3.50.0 */ destroy: function () { this.onChangeCallback = null; } }); module.exports = RGB; /***/ }), /***/ 60461: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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 {number} */ TOP_LEFT: 0, /** * A constant representing a top-center alignment or position. * @constant * @name Phaser.Display.Align.TOP_CENTER * @since 3.0.0 * @type {number} */ TOP_CENTER: 1, /** * A constant representing a top-right alignment or position. * @constant * @name Phaser.Display.Align.TOP_RIGHT * @since 3.0.0 * @type {number} */ TOP_RIGHT: 2, /** * A constant representing a left-top alignment or position. * @constant * @name Phaser.Display.Align.LEFT_TOP * @since 3.0.0 * @type {number} */ LEFT_TOP: 3, /** * A constant representing a left-center alignment or position. * @constant * @name Phaser.Display.Align.LEFT_CENTER * @since 3.0.0 * @type {number} */ LEFT_CENTER: 4, /** * A constant representing a left-bottom alignment or position. * @constant * @name Phaser.Display.Align.LEFT_BOTTOM * @since 3.0.0 * @type {number} */ LEFT_BOTTOM: 5, /** * A constant representing a center alignment or position. * @constant * @name Phaser.Display.Align.CENTER * @since 3.0.0 * @type {number} */ CENTER: 6, /** * A constant representing a right-top alignment or position. * @constant * @name Phaser.Display.Align.RIGHT_TOP * @since 3.0.0 * @type {number} */ RIGHT_TOP: 7, /** * A constant representing a right-center alignment or position. * @constant * @name Phaser.Display.Align.RIGHT_CENTER * @since 3.0.0 * @type {number} */ RIGHT_CENTER: 8, /** * A constant representing a right-bottom alignment or position. * @constant * @name Phaser.Display.Align.RIGHT_BOTTOM * @since 3.0.0 * @type {number} */ RIGHT_BOTTOM: 9, /** * A constant representing a bottom-left alignment or position. * @constant * @name Phaser.Display.Align.BOTTOM_LEFT * @since 3.0.0 * @type {number} */ BOTTOM_LEFT: 10, /** * A constant representing a bottom-center alignment or position. * @constant * @name Phaser.Display.Align.BOTTOM_CENTER * @since 3.0.0 * @type {number} */ BOTTOM_CENTER: 11, /** * A constant representing a bottom-right alignment or position. * @constant * @name Phaser.Display.Align.BOTTOM_RIGHT * @since 3.0.0 * @type {number} */ BOTTOM_RIGHT: 12 }; module.exports = ALIGN_CONST; /***/ }), /***/ 54312: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetBottom = __webpack_require__(62235); var GetCenterX = __webpack_require__(35893); var SetBottom = __webpack_require__(86327); var SetCenterX = __webpack_require__(88417); /** * Takes given Game Object and aligns it so that it is positioned in the bottom center of the other. * * @function Phaser.Display.Align.In.BottomCenter * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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 BottomCenter = function (gameObject, alignIn, offsetX, offsetY) { if (offsetX === undefined) { offsetX = 0; } if (offsetY === undefined) { offsetY = 0; } SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); SetBottom(gameObject, GetBottom(alignIn) + offsetY); return gameObject; }; module.exports = BottomCenter; /***/ }), /***/ 46768: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetBottom = __webpack_require__(62235); var GetLeft = __webpack_require__(26541); var SetBottom = __webpack_require__(86327); var SetLeft = __webpack_require__(385); /** * Takes given Game Object and aligns it so that it is positioned in the bottom left of the other. * * @function Phaser.Display.Align.In.BottomLeft * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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 BottomLeft = function (gameObject, alignIn, offsetX, offsetY) { if (offsetX === undefined) { offsetX = 0; } if (offsetY === undefined) { offsetY = 0; } SetLeft(gameObject, GetLeft(alignIn) - offsetX); SetBottom(gameObject, GetBottom(alignIn) + offsetY); return gameObject; }; module.exports = BottomLeft; /***/ }), /***/ 35827: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetBottom = __webpack_require__(62235); var GetRight = __webpack_require__(54380); var SetBottom = __webpack_require__(86327); var SetRight = __webpack_require__(40136); /** * Takes given Game Object and aligns it so that it is positioned in the bottom right of the other. * * @function Phaser.Display.Align.In.BottomRight * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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 BottomRight = function (gameObject, alignIn, offsetX, offsetY) { if (offsetX === undefined) { offsetX = 0; } if (offsetY === undefined) { offsetY = 0; } SetRight(gameObject, GetRight(alignIn) + offsetX); SetBottom(gameObject, GetBottom(alignIn) + offsetY); return gameObject; }; module.exports = BottomRight; /***/ }), /***/ 46871: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var CenterOn = __webpack_require__(66786); var GetCenterX = __webpack_require__(35893); var GetCenterY = __webpack_require__(7702); /** * Takes given Game Object and aligns it so that it is positioned in the center of the other. * * @function Phaser.Display.Align.In.Center * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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 Center = function (gameObject, alignIn, offsetX, offsetY) { if (offsetX === undefined) { offsetX = 0; } if (offsetY === undefined) { offsetY = 0; } CenterOn(gameObject, GetCenterX(alignIn) + offsetX, GetCenterY(alignIn) + offsetY); return gameObject; }; module.exports = Center; /***/ }), /***/ 5198: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetCenterY = __webpack_require__(7702); var GetLeft = __webpack_require__(26541); var SetCenterY = __webpack_require__(20786); var SetLeft = __webpack_require__(385); /** * Takes given Game Object and aligns it so that it is positioned in the left center of the other. * * @function Phaser.Display.Align.In.LeftCenter * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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 LeftCenter = function (gameObject, alignIn, offsetX, offsetY) { if (offsetX === undefined) { offsetX = 0; } if (offsetY === undefined) { offsetY = 0; } SetLeft(gameObject, GetLeft(alignIn) - offsetX); SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); return gameObject; }; module.exports = LeftCenter; /***/ }), /***/ 11879: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var ALIGN_CONST = __webpack_require__(60461); var AlignInMap = []; AlignInMap[ALIGN_CONST.BOTTOM_CENTER] = __webpack_require__(54312); AlignInMap[ALIGN_CONST.BOTTOM_LEFT] = __webpack_require__(46768); AlignInMap[ALIGN_CONST.BOTTOM_RIGHT] = __webpack_require__(35827); AlignInMap[ALIGN_CONST.CENTER] = __webpack_require__(46871); AlignInMap[ALIGN_CONST.LEFT_CENTER] = __webpack_require__(5198); AlignInMap[ALIGN_CONST.RIGHT_CENTER] = __webpack_require__(80503); AlignInMap[ALIGN_CONST.TOP_CENTER] = __webpack_require__(89698); AlignInMap[ALIGN_CONST.TOP_LEFT] = __webpack_require__(922); AlignInMap[ALIGN_CONST.TOP_RIGHT] = __webpack_require__(21373); AlignInMap[ALIGN_CONST.LEFT_BOTTOM] = AlignInMap[ALIGN_CONST.BOTTOM_LEFT]; AlignInMap[ALIGN_CONST.LEFT_TOP] = AlignInMap[ALIGN_CONST.TOP_LEFT]; AlignInMap[ALIGN_CONST.RIGHT_BOTTOM] = AlignInMap[ALIGN_CONST.BOTTOM_RIGHT]; AlignInMap[ALIGN_CONST.RIGHT_TOP] = AlignInMap[ALIGN_CONST.TOP_RIGHT]; /** * 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 * * @generic {Phaser.GameObjects.GameObject} G - [child,$return] * * @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 {number} 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; /***/ }), /***/ 80503: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetCenterY = __webpack_require__(7702); var GetRight = __webpack_require__(54380); var SetCenterY = __webpack_require__(20786); var SetRight = __webpack_require__(40136); /** * Takes given Game Object and aligns it so that it is positioned in the right center of the other. * * @function Phaser.Display.Align.In.RightCenter * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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 RightCenter = function (gameObject, alignIn, offsetX, offsetY) { if (offsetX === undefined) { offsetX = 0; } if (offsetY === undefined) { offsetY = 0; } SetRight(gameObject, GetRight(alignIn) + offsetX); SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); return gameObject; }; module.exports = RightCenter; /***/ }), /***/ 89698: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetCenterX = __webpack_require__(35893); var GetTop = __webpack_require__(17717); var SetCenterX = __webpack_require__(88417); var SetTop = __webpack_require__(66737); /** * Takes given Game Object and aligns it so that it is positioned in the top center of the other. * * @function Phaser.Display.Align.In.TopCenter * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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 TopCenter = function (gameObject, alignIn, offsetX, offsetY) { if (offsetX === undefined) { offsetX = 0; } if (offsetY === undefined) { offsetY = 0; } SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); SetTop(gameObject, GetTop(alignIn) - offsetY); return gameObject; }; module.exports = TopCenter; /***/ }), /***/ 922: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetLeft = __webpack_require__(26541); var GetTop = __webpack_require__(17717); var SetLeft = __webpack_require__(385); var SetTop = __webpack_require__(66737); /** * Takes given Game Object and aligns it so that it is positioned in the top left of the other. * * @function Phaser.Display.Align.In.TopLeft * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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 TopLeft = function (gameObject, alignIn, offsetX, offsetY) { if (offsetX === undefined) { offsetX = 0; } if (offsetY === undefined) { offsetY = 0; } SetLeft(gameObject, GetLeft(alignIn) - offsetX); SetTop(gameObject, GetTop(alignIn) - offsetY); return gameObject; }; module.exports = TopLeft; /***/ }), /***/ 21373: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetRight = __webpack_require__(54380); var GetTop = __webpack_require__(17717); var SetRight = __webpack_require__(40136); var SetTop = __webpack_require__(66737); /** * Takes given Game Object and aligns it so that it is positioned in the top right of the other. * * @function Phaser.Display.Align.In.TopRight * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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 TopRight = function (gameObject, alignIn, offsetX, offsetY) { if (offsetX === undefined) { offsetX = 0; } if (offsetY === undefined) { offsetY = 0; } SetRight(gameObject, GetRight(alignIn) + offsetX); SetTop(gameObject, GetTop(alignIn) - offsetY); return gameObject; }; module.exports = TopRight; /***/ }), /***/ 91660: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Display.Align.In */ module.exports = { BottomCenter: __webpack_require__(54312), BottomLeft: __webpack_require__(46768), BottomRight: __webpack_require__(35827), Center: __webpack_require__(46871), LeftCenter: __webpack_require__(5198), QuickSet: __webpack_require__(11879), RightCenter: __webpack_require__(80503), TopCenter: __webpack_require__(89698), TopLeft: __webpack_require__(922), TopRight: __webpack_require__(21373) }; /***/ }), /***/ 71926: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var CONST = __webpack_require__(60461); var Extend = __webpack_require__(79291); /** * @namespace Phaser.Display.Align */ var Align = { In: __webpack_require__(91660), To: __webpack_require__(16694) }; // Merge in the consts Align = Extend(false, Align, CONST); module.exports = Align; /***/ }), /***/ 21578: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetBottom = __webpack_require__(62235); var GetCenterX = __webpack_require__(35893); var SetCenterX = __webpack_require__(88417); var SetTop = __webpack_require__(66737); /** * 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 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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; /***/ }), /***/ 10210: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetBottom = __webpack_require__(62235); var GetLeft = __webpack_require__(26541); var SetLeft = __webpack_require__(385); var SetTop = __webpack_require__(66737); /** * 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 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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; /***/ }), /***/ 82341: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetBottom = __webpack_require__(62235); var GetRight = __webpack_require__(54380); var SetRight = __webpack_require__(40136); var SetTop = __webpack_require__(66737); /** * 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 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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; /***/ }), /***/ 87958: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetBottom = __webpack_require__(62235); var GetLeft = __webpack_require__(26541); var SetBottom = __webpack_require__(86327); var SetRight = __webpack_require__(40136); /** * 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 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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; /***/ }), /***/ 40080: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetCenterY = __webpack_require__(7702); var GetLeft = __webpack_require__(26541); var SetCenterY = __webpack_require__(20786); var SetRight = __webpack_require__(40136); /** * 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 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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; /***/ }), /***/ 88466: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetLeft = __webpack_require__(26541); var GetTop = __webpack_require__(17717); var SetRight = __webpack_require__(40136); var SetTop = __webpack_require__(66737); /** * 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 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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; /***/ }), /***/ 38829: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author samme * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var ALIGN_CONST = __webpack_require__(60461); var AlignToMap = []; AlignToMap[ALIGN_CONST.BOTTOM_CENTER] = __webpack_require__(21578); AlignToMap[ALIGN_CONST.BOTTOM_LEFT] = __webpack_require__(10210); AlignToMap[ALIGN_CONST.BOTTOM_RIGHT] = __webpack_require__(82341); AlignToMap[ALIGN_CONST.LEFT_BOTTOM] = __webpack_require__(87958); AlignToMap[ALIGN_CONST.LEFT_CENTER] = __webpack_require__(40080); AlignToMap[ALIGN_CONST.LEFT_TOP] = __webpack_require__(88466); AlignToMap[ALIGN_CONST.RIGHT_BOTTOM] = __webpack_require__(19211); AlignToMap[ALIGN_CONST.RIGHT_CENTER] = __webpack_require__(34609); AlignToMap[ALIGN_CONST.RIGHT_TOP] = __webpack_require__(48741); AlignToMap[ALIGN_CONST.TOP_CENTER] = __webpack_require__(49440); AlignToMap[ALIGN_CONST.TOP_LEFT] = __webpack_require__(81288); AlignToMap[ALIGN_CONST.TOP_RIGHT] = __webpack_require__(61323); /** * Takes a Game Object and aligns it next to another, at the given position. * The alignment used is based on the `position` argument, which is a `Phaser.Display.Align` property such as `LEFT_CENTER` or `TOP_RIGHT`. * * @function Phaser.Display.Align.To.QuickSet * @since 3.22.0 * * @generic {Phaser.GameObjects.GameObject} G - [child,$return] * * @param {Phaser.GameObjects.GameObject} child - The Game Object that will be positioned. * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. * @param {number} position - The position to align the Game Object with. This is an align constant, such as `Phaser.Display.Align.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, alignTo, position, offsetX, offsetY) { return AlignToMap[position](child, alignTo, offsetX, offsetY); }; module.exports = QuickSet; /***/ }), /***/ 19211: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetBottom = __webpack_require__(62235); var GetRight = __webpack_require__(54380); var SetBottom = __webpack_require__(86327); var SetLeft = __webpack_require__(385); /** * 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 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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; /***/ }), /***/ 34609: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetCenterY = __webpack_require__(7702); var GetRight = __webpack_require__(54380); var SetCenterY = __webpack_require__(20786); var SetLeft = __webpack_require__(385); /** * 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 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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; /***/ }), /***/ 48741: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetRight = __webpack_require__(54380); var GetTop = __webpack_require__(17717); var SetLeft = __webpack_require__(385); var SetTop = __webpack_require__(66737); /** * 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 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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; /***/ }), /***/ 49440: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetCenterX = __webpack_require__(35893); var GetTop = __webpack_require__(17717); var SetBottom = __webpack_require__(86327); var SetCenterX = __webpack_require__(88417); /** * 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 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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; /***/ }), /***/ 81288: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetLeft = __webpack_require__(26541); var GetTop = __webpack_require__(17717); var SetBottom = __webpack_require__(86327); var SetLeft = __webpack_require__(385); /** * 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 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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; /***/ }), /***/ 61323: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetRight = __webpack_require__(54380); var GetTop = __webpack_require__(17717); var SetBottom = __webpack_require__(86327); var SetRight = __webpack_require__(40136); /** * 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 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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; /***/ }), /***/ 16694: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Display.Align.To */ module.exports = { BottomCenter: __webpack_require__(21578), BottomLeft: __webpack_require__(10210), BottomRight: __webpack_require__(82341), LeftBottom: __webpack_require__(87958), LeftCenter: __webpack_require__(40080), LeftTop: __webpack_require__(88466), QuickSet: __webpack_require__(38829), RightBottom: __webpack_require__(19211), RightCenter: __webpack_require__(34609), RightTop: __webpack_require__(48741), TopCenter: __webpack_require__(49440), TopLeft: __webpack_require__(81288), TopRight: __webpack_require__(61323) }; /***/ }), /***/ 66786: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var SetCenterX = __webpack_require__(88417); var SetCenterY = __webpack_require__(20786); /** * Positions the Game Object so that it is centered on the given coordinates. * * @function Phaser.Display.Bounds.CenterOn * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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. */ var CenterOn = function (gameObject, x, y) { SetCenterX(gameObject, x); return SetCenterY(gameObject, y); }; module.exports = CenterOn; /***/ }), /***/ 62235: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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; /***/ }), /***/ 72873: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author samme * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetBottom = __webpack_require__(62235); var GetLeft = __webpack_require__(26541); var GetRight = __webpack_require__(54380); var GetTop = __webpack_require__(17717); var Rectangle = __webpack_require__(87841); /** * Returns the unrotated bounds of the Game Object as a rectangle. * * @function Phaser.Display.Bounds.GetBounds * @since 3.24.0 * * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. * @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 bounds of the Game Object. */ var GetBounds = function (gameObject, output) { if (output === undefined) { output = new Rectangle(); } var left = GetLeft(gameObject); var top = GetTop(gameObject); output.x = left; output.y = top; output.width = GetRight(gameObject) - left; output.height = GetBottom(gameObject) - top; return output; }; module.exports = GetBounds; /***/ }), /***/ 35893: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * Returns the center x coordinate from the bounds of the Game Object. * * @function Phaser.Display.Bounds.GetCenterX * @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. */ var GetCenterX = function (gameObject) { return gameObject.x - (gameObject.width * gameObject.originX) + (gameObject.width * 0.5); }; module.exports = GetCenterX; /***/ }), /***/ 7702: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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; /***/ }), /***/ 26541: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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; /***/ }), /***/ 87431: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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; /***/ }), /***/ 46928: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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; /***/ }), /***/ 54380: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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; /***/ }), /***/ 17717: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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; /***/ }), /***/ 86327: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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; /***/ }), /***/ 88417: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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; /***/ }), /***/ 20786: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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; /***/ }), /***/ 385: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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; /***/ }), /***/ 40136: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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; /***/ }), /***/ 66737: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @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; /***/ }), /***/ 58724: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Display.Bounds */ module.exports = { CenterOn: __webpack_require__(66786), GetBottom: __webpack_require__(62235), GetBounds: __webpack_require__(72873), GetCenterX: __webpack_require__(35893), GetCenterY: __webpack_require__(7702), GetLeft: __webpack_require__(26541), GetOffsetX: __webpack_require__(87431), GetOffsetY: __webpack_require__(46928), GetRight: __webpack_require__(54380), GetTop: __webpack_require__(17717), SetBottom: __webpack_require__(86327), SetCenterX: __webpack_require__(88417), SetCenterY: __webpack_require__(20786), SetLeft: __webpack_require__(385), SetRight: __webpack_require__(40136), SetTop: __webpack_require__(66737) }; /***/ }), /***/ 20623: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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', '-moz-crisp-edges', '-o-crisp-edges', '-webkit-optimize-contrast', 'optimize-contrast', 'crisp-edges', '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; /***/ }), /***/ 27919: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var CONST = __webpack_require__(8054); var Smoothing = __webpack_require__(68703); // The pool into which the canvas elements are placed. var pool = []; // Automatically apply smoothing(false) to created Canvas elements var _disableContextSmoothing = false; /** * The CanvasPool is a global static object, that allows Phaser to recycle and pool 2D Context Canvas DOM elements. * It does not pool WebGL Contexts, because once the context options are set they cannot be modified again, * which is useless for some of the Phaser pipelines / renderer. * * 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 on the same page can share the one single pool. * * @namespace Phaser.Display.Canvas.CanvasPool * @since 3.0.0 */ var CanvasPool = function () { /** * Creates a new Canvas DOM element, or pulls one from the pool if free. * * @function Phaser.Display.Canvas.CanvasPool.create * @since 3.0.0 * * @param {*} parent - The parent of the Canvas object. * @param {number} [width=1] - The width of the Canvas. * @param {number} [height=1] - The height of the Canvas. * @param {number} [canvasType=Phaser.CANVAS] - The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`. * @param {boolean} [selfParent=false] - Use the generated Canvas element as the parent? * * @return {HTMLCanvasElement} The canvas element that was created or pulled from the pool */ var create = function (parent, width, height, canvasType, selfParent) { if (width === undefined) { width = 1; } if (height === undefined) { height = 1; } if (canvasType === undefined) { canvasType = CONST.CANVAS; } if (selfParent === undefined) { selfParent = false; } var canvas; var container = first(canvasType); if (container === null) { container = { parent: parent, canvas: document.createElement('canvas'), type: canvasType }; if (canvasType === CONST.CANVAS) { pool.push(container); } canvas = container.canvas; } else { container.parent = parent; canvas = container.canvas; } if (selfParent) { container.parent = canvas; } canvas.width = width; canvas.height = height; if (_disableContextSmoothing && canvasType === CONST.CANVAS) { Smoothing.disable(canvas.getContext('2d', { willReadFrequently: false })); } return canvas; }; /** * Creates a new Canvas DOM element, or pulls one from the pool if free. * * @function Phaser.Display.Canvas.CanvasPool.create2D * @since 3.0.0 * * @param {*} parent - The parent of the Canvas object. * @param {number} [width=1] - The width of the Canvas. * @param {number} [height=1] - The height of the Canvas. * * @return {HTMLCanvasElement} The created canvas. */ var create2D = function (parent, width, height) { return create(parent, width, height, CONST.CANVAS); }; /** * Creates a new Canvas DOM element, or pulls one from the pool if free. * * @function Phaser.Display.Canvas.CanvasPool.createWebGL * @since 3.0.0 * * @param {*} parent - The parent of the Canvas object. * @param {number} [width=1] - The width of the Canvas. * @param {number} [height=1] - The height of the Canvas. * * @return {HTMLCanvasElement} The created WebGL canvas. */ var createWebGL = function (parent, width, height) { return create(parent, width, height, CONST.WEBGL); }; /** * Gets the first free canvas index from the pool. * * @function Phaser.Display.Canvas.CanvasPool.first * @since 3.0.0 * * @param {number} [canvasType=Phaser.CANVAS] - The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`. * * @return {HTMLCanvasElement} The first free canvas, or `null` if a WebGL canvas was requested or if the pool doesn't have free canvases. */ var first = function (canvasType) { if (canvasType === undefined) { canvasType = CONST.CANVAS; } if (canvasType === CONST.WEBGL) { return null; } for (var i = 0; i < pool.length; i++) { var container = pool[i]; if (!container.parent && container.type === canvasType) { return container; } } return null; }; /** * Looks up a canvas based on its parent, and if found puts it back in the pool, freeing it up for re-use. * The canvas has its width and height set to 1, and its parent attribute nulled. * * @function Phaser.Display.Canvas.CanvasPool.remove * @since 3.0.0 * * @param {*} parent - The canvas or the parent of the canvas to free. */ var remove = function (parent) { // Check to see if the parent is a canvas object var isCanvas = parent instanceof HTMLCanvasElement; pool.forEach(function (container) { if ((isCanvas && container.canvas === parent) || (!isCanvas && container.parent === parent)) { container.parent = null; container.canvas.width = 1; container.canvas.height = 1; } }); }; /** * Gets the total number of used canvas elements in the pool. * * @function Phaser.Display.Canvas.CanvasPool.total * @since 3.0.0 * * @return {number} The number of used canvases. */ var total = function () { var c = 0; pool.forEach(function (container) { if (container.parent) { c++; } }); return c; }; /** * Gets the total number of free canvas elements in the pool. * * @function Phaser.Display.Canvas.CanvasPool.free * @since 3.0.0 * * @return {number} The number of free canvases. */ var free = function () { return pool.length - total(); }; /** * Disable context smoothing on any new Canvas element created. * * @function Phaser.Display.Canvas.CanvasPool.disableSmoothing * @since 3.0.0 */ var disableSmoothing = function () { _disableContextSmoothing = true; }; /** * Enable context smoothing on any new Canvas element created. * * @function Phaser.Display.Canvas.CanvasPool.enableSmoothing * @since 3.0.0 */ var enableSmoothing = function () { _disableContextSmoothing = false; }; return { create2D: create2D, create: create, createWebGL: createWebGL, disableSmoothing: disableSmoothing, enableSmoothing: enableSmoothing, first: first, free: free, pool: pool, remove: remove, total: total }; }; // If we export the called function here, it'll only be invoked once (not every time it's required). module.exports = CanvasPool(); /***/ }), /***/ 68703: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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 - The canvas context to check. * * @return {string} The name of the property on the context which controls image smoothing (either `imageSmoothingEnabled` or a vendor-prefixed version thereof), or `null` if not supported. */ 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 - The context on which to enable smoothing. * * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} The provided context. */ 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 - The context on which to disable smoothing. * * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} The provided context. */ 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 - The context to check. * * @return {?boolean} `true` if smoothing is enabled on the context, otherwise `false`. `null` if not supported. */ var isEnabled = function (context) { return (prefix !== null) ? context[prefix] : null; }; return { disable: disable, enable: enable, getPrefix: getPrefix, isEnabled: isEnabled }; }; module.exports = Smoothing(); /***/ }), /***/ 65208: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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; /***/ }), /***/ 91610: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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; /***/ }), /***/ 26253: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Display.Canvas */ module.exports = { CanvasInterpolation: __webpack_require__(20623), CanvasPool: __webpack_require__(27919), Smoothing: __webpack_require__(68703), TouchAction: __webpack_require__(65208), UserSelect: __webpack_require__(91610) }; /***/ }), /***/ 40987: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Class = __webpack_require__(83419); var GetColor = __webpack_require__(37589); var GetColor32 = __webpack_require__(1000); var HSVToRGB = __webpack_require__(7537); var RGBToHSV = __webpack_require__(87837); /** * @namespace Phaser.Display.Color */ /** * @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 {number} [red=0] - The red color value. A number between 0 and 255. * @param {number} [green=0] - The green color value. A number between 0 and 255. * @param {number} [blue=0] - The blue color value. A number between 0 and 255. * @param {number} [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; /** * The hue color value. A number between 0 and 1. * This is the base color. * * @name Phaser.Display.Color#_h * @type {number} * @default 0 * @private * @since 3.13.0 */ this._h = 0; /** * The saturation color value. A number between 0 and 1. * This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. * * @name Phaser.Display.Color#_s * @type {number} * @default 0 * @private * @since 3.13.0 */ this._s = 0; /** * The lightness color value. A number between 0 and 1. * This controls how dark the color is. Where 1 is as bright as possible and 0 is black. * * @name Phaser.Display.Color#_v * @type {number} * @default 0 * @private * @since 3.13.0 */ this._v = 0; /** * Is this color update locked? * * @name Phaser.Display.Color#_locked * @type {boolean} * @private * @since 3.13.0 */ this._locked = false; /** * 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._locked = true; this.red = 0; this.green = 0; this.blue = 0; this.alpha = 0; this._locked = false; return this.update(true); }, /** * Sets the color of this Color component. * * @method Phaser.Display.Color#setTo * @since 3.0.0 * * @param {number} red - The red color value. A number between 0 and 255. * @param {number} green - The green color value. A number between 0 and 255. * @param {number} blue - The blue color value. A number between 0 and 255. * @param {number} [alpha=255] - The alpha value. A number between 0 and 255. * @param {boolean} [updateHSV=true] - Update the HSV values after setting the RGB values? * * @return {Phaser.Display.Color} This Color object. */ setTo: function (red, green, blue, alpha, updateHSV) { if (alpha === undefined) { alpha = 255; } if (updateHSV === undefined) { updateHSV = true; } this._locked = true; this.red = red; this.green = green; this.blue = blue; this.alpha = alpha; this._locked = false; return this.update(updateHSV); }, /** * Sets the red, green, blue and alpha GL values of this Color component. * * @method Phaser.Display.Color#setGLTo * @since 3.0.0 * * @param {number} red - The red color value. A number between 0 and 1. * @param {number} green - The green color value. A number between 0 and 1. * @param {number} blue - The blue color value. A number between 0 and 1. * @param {number} [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._locked = true; this.redGL = red; this.greenGL = green; this.blueGL = blue; this.alphaGL = alpha; this._locked = false; return this.update(true); }, /** * Sets the color based on the color object given. * * @method Phaser.Display.Color#setFromRGB * @since 3.0.0 * * @param {Phaser.Types.Display.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._locked = true; this.red = color.r; this.green = color.g; this.blue = color.b; if (color.hasOwnProperty('a')) { this.alpha = color.a; } this._locked = false; return this.update(true); }, /** * Sets the color based on the hue, saturation and lightness values given. * * @method Phaser.Display.Color#setFromHSV * @since 3.13.0 * * @param {number} h - The hue, in the range 0 - 1. This is the base color. * @param {number} s - The saturation, in the range 0 - 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. * @param {number} v - The value, in the range 0 - 1. This controls how dark the color is. Where 1 is as bright as possible and 0 is black. * * @return {Phaser.Display.Color} This Color object. */ setFromHSV: function (h, s, v) { return HSVToRGB(h, s, v, this); }, /** * Updates the internal cache values. * * @method Phaser.Display.Color#update * @private * @since 3.0.0 * * @return {Phaser.Display.Color} This Color object. */ update: function (updateHSV) { if (updateHSV === undefined) { updateHSV = false; } if (this._locked) { return this; } var r = this.r; var g = this.g; var b = this.b; var a = this.a; this._color = GetColor(r, g, b); this._color32 = GetColor32(r, g, b, a); this._rgba = 'rgba(' + r + ',' + g + ',' + b + ',' + (a / 255) + ')'; if (updateHSV) { RGBToHSV(r, g, b, this); } return this; }, /** * Updates the internal hsv cache values. * * @method Phaser.Display.Color#updateHSV * @private * @since 3.13.0 * * @return {Phaser.Display.Color} This Color object. */ updateHSV: function () { var r = this.r; var g = this.g; var b = this.b; RGBToHSV(r, g, b, this); 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); }, /** * Sets this Color object to be grayscaled based on the shade value given. * * @method Phaser.Display.Color#gray * @since 3.13.0 * * @param {number} shade - A value between 0 and 255. * * @return {Phaser.Display.Color} This Color object. */ gray: function (shade) { return this.setTo(shade, shade, shade); }, /** * Sets this Color object to be a random color between the `min` and `max` values given. * * @method Phaser.Display.Color#random * @since 3.13.0 * * @param {number} [min=0] - The minimum random color value. Between 0 and 255. * @param {number} [max=255] - The maximum random color value. Between 0 and 255. * * @return {Phaser.Display.Color} This Color object. */ random: function (min, max) { if (min === undefined) { min = 0; } if (max === undefined) { max = 255; } var r = Math.floor(min + Math.random() * (max - min)); var g = Math.floor(min + Math.random() * (max - min)); var b = Math.floor(min + Math.random() * (max - min)); return this.setTo(r, g, b); }, /** * Sets this Color object to be a random grayscale color between the `min` and `max` values given. * * @method Phaser.Display.Color#randomGray * @since 3.13.0 * * @param {number} [min=0] - The minimum random color value. Between 0 and 255. * @param {number} [max=255] - The maximum random color value. Between 0 and 255. * * @return {Phaser.Display.Color} This Color object. */ randomGray: function (min, max) { if (min === undefined) { min = 0; } if (max === undefined) { max = 255; } var s = Math.floor(min + Math.random() * (max - min)); return this.setTo(s, s, s); }, /** * Increase the saturation of this Color by the percentage amount given. * The saturation is the amount of the base color in the hue. * * @method Phaser.Display.Color#saturate * @since 3.13.0 * * @param {number} amount - The percentage amount to change this color by. A value between 0 and 100. * * @return {Phaser.Display.Color} This Color object. */ saturate: function (amount) { this.s += amount / 100; return this; }, /** * Decrease the saturation of this Color by the percentage amount given. * The saturation is the amount of the base color in the hue. * * @method Phaser.Display.Color#desaturate * @since 3.13.0 * * @param {number} amount - The percentage amount to change this color by. A value between 0 and 100. * * @return {Phaser.Display.Color} This Color object. */ desaturate: function (amount) { this.s -= amount / 100; return this; }, /** * Increase the lightness of this Color by the percentage amount given. * * @method Phaser.Display.Color#lighten * @since 3.13.0 * * @param {number} amount - The percentage amount to change this color by. A value between 0 and 100. * * @return {Phaser.Display.Color} This Color object. */ lighten: function (amount) { this.v += amount / 100; return this; }, /** * Decrease the lightness of this Color by the percentage amount given. * * @method Phaser.Display.Color#darken * @since 3.13.0 * * @param {number} amount - The percentage amount to change this color by. A value between 0 and 100. * * @return {Phaser.Display.Color} This Color object. */ darken: function (amount) { this.v -= amount / 100; return this; }, /** * Brighten this Color by the percentage amount given. * * @method Phaser.Display.Color#brighten * @since 3.13.0 * * @param {number} amount - The percentage amount to change this color by. A value between 0 and 100. * * @return {Phaser.Display.Color} This Color object. */ brighten: function (amount) { var r = this.r; var g = this.g; var b = this.b; r = Math.max(0, Math.min(255, r - Math.round(255 * - (amount / 100)))); g = Math.max(0, Math.min(255, g - Math.round(255 * - (amount / 100)))); b = Math.max(0, Math.min(255, b - Math.round(255 * - (amount / 100)))); return this.setTo(r, g, b); }, /** * 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 {number} * @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(true); } }, /** * The green color value, normalized to the range 0 to 1. * * @name Phaser.Display.Color#greenGL * @type {number} * @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(true); } }, /** * The blue color value, normalized to the range 0 to 1. * * @name Phaser.Display.Color#blueGL * @type {number} * @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(true); } }, /** * The alpha color value, normalized to the range 0 to 1. * * @name Phaser.Display.Color#alphaGL * @type {number} * @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(true); } }, /** * 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(true); } }, /** * 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(true); } }, /** * 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(); } }, /** * The hue color value. A number between 0 and 1. * This is the base color. * * @name Phaser.Display.Color#h * @type {number} * @since 3.13.0 */ h: { get: function () { return this._h; }, set: function (value) { this._h = value; HSVToRGB(value, this._s, this._v, this); } }, /** * The saturation color value. A number between 0 and 1. * This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. * * @name Phaser.Display.Color#s * @type {number} * @since 3.13.0 */ s: { get: function () { return this._s; }, set: function (value) { this._s = value; HSVToRGB(this._h, value, this._v, this); } }, /** * The lightness color value. A number between 0 and 1. * This controls how dark the color is. Where 1 is as bright as possible and 0 is black. * * @name Phaser.Display.Color#v * @type {number} * @since 3.13.0 */ v: { get: function () { return this._v; }, set: function (value) { this._v = value; HSVToRGB(this._h, this._s, value, this); } } }); module.exports = Color; /***/ }), /***/ 92728: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetColor = __webpack_require__(37589); /** * Return an array of Colors in a Color Spectrum. * * The spectrum colors flow in the order: red, yellow, green, blue. * * By default this function will return an array with 1024 elements in. * * However, you can reduce this to a smaller quantity if needed, by specitying the `limit` parameter. * * @function Phaser.Display.Color.ColorSpectrum * @since 3.50.0 * * @param {number} [limit=1024] - How many colors should be returned? The maximum is 1024 but you can set a smaller quantity if required. * * @return {Phaser.Types.Display.ColorObject[]} An array containing `limit` parameter number of elements, where each contains a Color Object. */ var ColorSpectrum = function (limit) { if (limit === undefined) { limit = 1024; } var colors = []; var range = 255; var i; var r = 255; var g = 0; var b = 0; // Red to Yellow for (i = 0; i <= range; i++) { colors.push({ r: r, g: i, b: b, color: GetColor(r, i, b) }); } g = 255; // Yellow to Green for (i = range; i >= 0; i--) { colors.push({ r: i, g: g, b: b, color: GetColor(i, g, b) }); } r = 0; // Green to Blue for (i = 0; i <= range; i++, g--) { colors.push({ r: r, g: g, b: i, color: GetColor(r, g, i) }); } g = 0; b = 255; // Blue to Red for (i = 0; i <= range; i++, b--, r++) { colors.push({ r: r, g: g, b: b, color: GetColor(r, g, b) }); } if (limit === 1024) { return colors; } else { var out = []; var t = 0; var inc = 1024 / limit; for (i = 0; i < limit; i++) { out.push(colors[Math.floor(t)]); t += inc; } return out; } }; module.exports = ColorSpectrum; /***/ }), /***/ 91588: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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 {Phaser.Types.Display.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; /***/ }), /***/ 62957: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * Returns a string containing a hex representation of the given color component. * * @function Phaser.Display.Color.ComponentToHex * @since 3.0.0 * * @param {number} color - The color channel to get the hex value for, must be a value between 0 and 255. * * @return {string} A string of length 2 characters, i.e. 255 = ff, 100 = 64. */ var ComponentToHex = function (color) { var hex = color.toString(16); return (hex.length === 1) ? '0' + hex : hex; }; module.exports = ComponentToHex; /***/ }), /***/ 37589: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * Given 3 separate color values this will return an integer representation of it. * * @function Phaser.Display.Color.GetColor * @since 3.0.0 * * @param {number} red - The red color value. A number between 0 and 255. * @param {number} green - The green color value. A number between 0 and 255. * @param {number} blue - The blue color value. A number between 0 and 255. * * @return {number} The combined color value. */ var GetColor = function (red, green, blue) { return red << 16 | green << 8 | blue; }; module.exports = GetColor; /***/ }), /***/ 1000: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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 {number} red - The red color value. A number between 0 and 255. * @param {number} green - The green color value. A number between 0 and 255. * @param {number} blue - The blue color value. A number between 0 and 255. * @param {number} 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; /***/ }), /***/ 62183: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Color = __webpack_require__(40987); var HueToComponent = __webpack_require__(89528); /** * 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; /***/ }), /***/ 27939: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var HSVToRGB = __webpack_require__(7537); /** * Generates an HSV color wheel which is an array of 360 Color objects, for each step of the wheel. * * @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 {Phaser.Types.Display.ColorObject[]} An array containing 360 ColorObject elements, where each element contains a Color object 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; /***/ }), /***/ 7537: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var GetColor = __webpack_require__(37589); /** * RGB space conversion. * * @ignore * * @param {number} n - The value to convert. * @param {number} h - The h value. * @param {number} s - The s value. * @param {number} v - The v value. * * @return {number} The converted value. */ function ConvertValue (n, h, s, v) { var k = (n + h * 6) % 6; var min = Math.min(k, 4 - k, 1); return Math.round(255 * (v - v * s * Math.max(0, min))); } /** * Converts a HSV (hue, saturation and value) color set to RGB. * * Conversion formula from https://en.wikipedia.org/wiki/HSL_and_HSV * * Assumes HSV values are contained in the set [0, 1]. * * @function Phaser.Display.Color.HSVToRGB * @since 3.0.0 * * @param {number} h - The hue, in the range 0 - 1. This is the base color. * @param {number} s - The saturation, in the range 0 - 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. * @param {number} v - The value, in the range 0 - 1. This controls how dark the color is. Where 1 is as bright as possible and 0 is black. * @param {(Phaser.Types.Display.ColorObject|Phaser.Display.Color)} [out] - A Color object to store the results in. If not given a new ColorObject will be created. * * @return {(Phaser.Types.Display.ColorObject|Phaser.Display.Color)} An object with the red, green and blue values set in the r, g and b properties. */ var HSVToRGB = function (h, s, v, out) { if (s === undefined) { s = 1; } if (v === undefined) { v = 1; } var r = ConvertValue(5, h, s, v); var g = ConvertValue(3, h, s, v); var b = ConvertValue(1, h, s, v); if (!out) { return { r: r, g: g, b: b, color: GetColor(r, g, b) }; } else if (out.setTo) { return out.setTo(r, g, b, out.alpha, true); } else { out.r = r; out.g = g; out.b = b; out.color = GetColor(r, g, b); return out; } }; module.exports = HSVToRGB; /***/ }), /***/ 70238: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Color = __webpack_require__(40987); /** * 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; /***/ }), /***/ 89528: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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.exports = HueToComponent; /***/ }), /***/ 30100: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Color = __webpack_require__(40987); var IntegerToRGB = __webpack_require__(90664); /** * Converts the given color value into an instance of a Color object. * * @function Phaser.Display.Color.IntegerToColor * @since 3.0.0 * * @param {number} 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; /***/ }), /***/ 90664: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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 {number} input - The color value to convert into a Color object. * * @return {Phaser.Types.Display.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; /***/ }), /***/ 13699: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Linear = __webpack_require__(28915); /** * @namespace Phaser.Display.Color.Interpolate * @memberof Phaser.Display.Color * @since 3.0.0 */ /** * Interpolates between the two given color ranges over the length supplied. * * @function Phaser.Display.Color.Interpolate.RGBWithRGB * @memberof Phaser.Display.Color.Interpolate * @static * @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 {Phaser.Types.Display.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 * @memberof Phaser.Display.Color.Interpolate * @static * @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 {Phaser.Types.Display.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 * @memberof Phaser.Display.Color.Interpolate * @static * @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 {Phaser.Types.Display.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 }; /***/ }), /***/ 68957: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Color = __webpack_require__(40987); /** * 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 {Phaser.Types.Display.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; /***/ }), /***/ 87388: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Color = __webpack_require__(40987); /** * 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; /***/ }), /***/ 87837: /***/ ((module) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * Converts an RGB color value to HSV (hue, saturation and value). * Conversion formula 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 {number} r - The red color value. A number between 0 and 255. * @param {number} g - The green color value. A number between 0 and 255. * @param {number} b - The blue color value. A number between 0 and 255. * @param {(Phaser.Types.Display.HSVColorObject|Phaser.Display.Color)} [out] - An object to store the color values in. If not given an HSV Color Object will be created. * * @return {(Phaser.Types.Display.HSVColorObject|Phaser.Display.Color)} An object with the properties `h`, `s` and `v` set. */ var RGBToHSV = function (r, g, b, out) { if (out === undefined) { out = { h: 0, s: 0, v: 0 }; } 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; } if (out.hasOwnProperty('_h')) { out._h = h; out._s = s; out._v = v; } else { out.h = h; out.s = s; out.v = v; } return out; }; module.exports = RGBToHSV; /***/ }), /***/ 75723: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var ComponentToHex = __webpack_require__(62957); /** * 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 {number} r - The red color value. A number between 0 and 255. * @param {number} g - The green color value. A number between 0 and 255. * @param {number} b - The blue color value. A number between 0 and 255. * @param {number} [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, 7); } else { return '0x' + ComponentToHex(a) + ComponentToHex(r) + ComponentToHex(g) + ComponentToHex(b); } }; module.exports = RGBToString; /***/ }), /***/ 85386: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Between = __webpack_require__(30976); var Color = __webpack_require__(40987); /** * 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 {number} [min=0] - The minimum value to set the random range from (between 0 and 255) * @param {number} [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; /***/ }), /***/ 80333: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var HexStringToColor = __webpack_require__(70238); var IntegerToColor = __webpack_require__(30100); var ObjectToColor = __webpack_require__(68957); var RGBStringToColor = __webpack_require__(87388); /** * 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.Display.Color.ValueToColor * @since 3.0.0 * * @param {(string|number|Phaser.Types.Display.InputColorObject)} input - The source color value to convert. * * @return {Phaser.Display.Color} A Color object. */ var ValueToColor = function (input) { var t = typeof input; switch (t) { case 'string': if (input.substr(0, 3).toLowerCase() === 'rgb') { return RGBStringToColor(input); } else { return HexStringToColor(input); } case 'number': return IntegerToColor(input); case 'object': return ObjectToColor(input); } }; module.exports = ValueToColor; /***/ }), /***/ 3956: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ var Color = __webpack_require__(40987); Color.ColorSpectrum = __webpack_require__(92728); Color.ColorToRGBA = __webpack_require__(91588); Color.ComponentToHex = __webpack_require__(62957); Color.GetColor = __webpack_require__(37589); Color.GetColor32 = __webpack_require__(1000); Color.HexStringToColor = __webpack_require__(70238); Color.HSLToColor = __webpack_require__(62183); Color.HSVColorWheel = __webpack_require__(27939); Color.HSVToRGB = __webpack_require__(7537); Color.HueToComponent = __webpack_require__(89528); Color.IntegerToColor = __webpack_require__(30100); Color.IntegerToRGB = __webpack_require__(90664); Color.Interpolate = __webpack_require__(13699); Color.ObjectToColor = __webpack_require__(68957); Color.RandomRGB = __webpack_require__(85386); Color.RGBStringToColor = __webpack_require__(87388); Color.RGBToHSV = __webpack_require__(87837); Color.RGBToString = __webpack_require__(75723); Color.ValueToColor = __webpack_require__(80333); module.exports = Color; /***/ }), /***/ 27460: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey * @copyright 2013-2024 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @namespace Phaser.Display */ module.exports = { Align: __webpack_require__(71926), BaseShader: __webpack_require__(73894), Bounds: __webpack_require__(58724), Canvas: __webpack_require__(26253), Color: __webpack_require__(3956), ColorMatrix: __webpack_require__(89422), Masks: __webpack_require__(69781), RGB: __webpack_require__(51767) }; /***/ }), /***/ 6858: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * @author Richard Davey