phaser
Version:
A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers.
1,613 lines (1,392 loc) • 1.66 MB
JavaScript
window["SpinePlugin"] =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./SpinePlugin.js");
/******/ })
/************************************************************************/
/******/ ({
/***/ "../../../node_modules/eventemitter3/index.js":
/*!**************************************************************!*\
!*** D:/wamp/www/phaser/node_modules/eventemitter3/index.js ***!
\**************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"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;
}
/***/ }),
/***/ "../../../src/core/events/BLUR_EVENT.js":
/*!********************************************************!*\
!*** D:/wamp/www/phaser/src/core/events/BLUR_EVENT.js ***!
\********************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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
* @since 3.0.0
*/
module.exports = 'blur';
/***/ }),
/***/ "../../../src/core/events/BOOT_EVENT.js":
/*!********************************************************!*\
!*** D:/wamp/www/phaser/src/core/events/BOOT_EVENT.js ***!
\********************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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
* @since 3.0.0
*/
module.exports = 'boot';
/***/ }),
/***/ "../../../src/core/events/CONTEXT_LOST_EVENT.js":
/*!****************************************************************!*\
!*** D:/wamp/www/phaser/src/core/events/CONTEXT_LOST_EVENT.js ***!
\****************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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 partner event is `CONTEXT_RESTORED`.
*
* @event Phaser.Core.Events#CONTEXT_LOST
* @since 3.19.0
*/
module.exports = 'contextlost';
/***/ }),
/***/ "../../../src/core/events/CONTEXT_RESTORED_EVENT.js":
/*!********************************************************************!*\
!*** D:/wamp/www/phaser/src/core/events/CONTEXT_RESTORED_EVENT.js ***!
\********************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Game Context Restored Event.
*
* This event is dispatched by the Game if the WebGL Renderer it is using encounters a WebGL Context Restored event from the browser.
*
* The partner event is `CONTEXT_LOST`.
*
* @event Phaser.Core.Events#CONTEXT_RESTORED
* @since 3.19.0
*/
module.exports = 'contextrestored';
/***/ }),
/***/ "../../../src/core/events/DESTROY_EVENT.js":
/*!***********************************************************!*\
!*** D:/wamp/www/phaser/src/core/events/DESTROY_EVENT.js ***!
\***********************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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
* @since 3.0.0
*/
module.exports = 'destroy';
/***/ }),
/***/ "../../../src/core/events/FOCUS_EVENT.js":
/*!*********************************************************!*\
!*** D:/wamp/www/phaser/src/core/events/FOCUS_EVENT.js ***!
\*********************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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
* @since 3.0.0
*/
module.exports = 'focus';
/***/ }),
/***/ "../../../src/core/events/HIDDEN_EVENT.js":
/*!**********************************************************!*\
!*** D:/wamp/www/phaser/src/core/events/HIDDEN_EVENT.js ***!
\**********************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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
* @since 3.0.0
*/
module.exports = 'hidden';
/***/ }),
/***/ "../../../src/core/events/PAUSE_EVENT.js":
/*!*********************************************************!*\
!*** D:/wamp/www/phaser/src/core/events/PAUSE_EVENT.js ***!
\*********************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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
* @since 3.0.0
*/
module.exports = 'pause';
/***/ }),
/***/ "../../../src/core/events/POST_RENDER_EVENT.js":
/*!***************************************************************!*\
!*** D:/wamp/www/phaser/src/core/events/POST_RENDER_EVENT.js ***!
\***************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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
* @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';
/***/ }),
/***/ "../../../src/core/events/POST_STEP_EVENT.js":
/*!*************************************************************!*\
!*** D:/wamp/www/phaser/src/core/events/POST_STEP_EVENT.js ***!
\*************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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
* @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';
/***/ }),
/***/ "../../../src/core/events/PRE_RENDER_EVENT.js":
/*!**************************************************************!*\
!*** D:/wamp/www/phaser/src/core/events/PRE_RENDER_EVENT.js ***!
\**************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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
* @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';
/***/ }),
/***/ "../../../src/core/events/PRE_STEP_EVENT.js":
/*!************************************************************!*\
!*** D:/wamp/www/phaser/src/core/events/PRE_STEP_EVENT.js ***!
\************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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
* @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';
/***/ }),
/***/ "../../../src/core/events/READY_EVENT.js":
/*!*********************************************************!*\
!*** D:/wamp/www/phaser/src/core/events/READY_EVENT.js ***!
\*********************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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
* @since 3.0.0
*/
module.exports = 'ready';
/***/ }),
/***/ "../../../src/core/events/RESUME_EVENT.js":
/*!**********************************************************!*\
!*** D:/wamp/www/phaser/src/core/events/RESUME_EVENT.js ***!
\**********************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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
* @since 3.0.0
*/
module.exports = 'resume';
/***/ }),
/***/ "../../../src/core/events/STEP_EVENT.js":
/*!********************************************************!*\
!*** D:/wamp/www/phaser/src/core/events/STEP_EVENT.js ***!
\********************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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
* @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';
/***/ }),
/***/ "../../../src/core/events/VISIBLE_EVENT.js":
/*!***********************************************************!*\
!*** D:/wamp/www/phaser/src/core/events/VISIBLE_EVENT.js ***!
\***********************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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
* @since 3.0.0
*/
module.exports = 'visible';
/***/ }),
/***/ "../../../src/core/events/index.js":
/*!***************************************************!*\
!*** D:/wamp/www/phaser/src/core/events/index.js ***!
\***************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* @namespace Phaser.Core.Events
*/
module.exports = {
BLUR: __webpack_require__(/*! ./BLUR_EVENT */ "../../../src/core/events/BLUR_EVENT.js"),
BOOT: __webpack_require__(/*! ./BOOT_EVENT */ "../../../src/core/events/BOOT_EVENT.js"),
CONTEXT_LOST: __webpack_require__(/*! ./CONTEXT_LOST_EVENT */ "../../../src/core/events/CONTEXT_LOST_EVENT.js"),
CONTEXT_RESTORED: __webpack_require__(/*! ./CONTEXT_RESTORED_EVENT */ "../../../src/core/events/CONTEXT_RESTORED_EVENT.js"),
DESTROY: __webpack_require__(/*! ./DESTROY_EVENT */ "../../../src/core/events/DESTROY_EVENT.js"),
FOCUS: __webpack_require__(/*! ./FOCUS_EVENT */ "../../../src/core/events/FOCUS_EVENT.js"),
HIDDEN: __webpack_require__(/*! ./HIDDEN_EVENT */ "../../../src/core/events/HIDDEN_EVENT.js"),
PAUSE: __webpack_require__(/*! ./PAUSE_EVENT */ "../../../src/core/events/PAUSE_EVENT.js"),
POST_RENDER: __webpack_require__(/*! ./POST_RENDER_EVENT */ "../../../src/core/events/POST_RENDER_EVENT.js"),
POST_STEP: __webpack_require__(/*! ./POST_STEP_EVENT */ "../../../src/core/events/POST_STEP_EVENT.js"),
PRE_RENDER: __webpack_require__(/*! ./PRE_RENDER_EVENT */ "../../../src/core/events/PRE_RENDER_EVENT.js"),
PRE_STEP: __webpack_require__(/*! ./PRE_STEP_EVENT */ "../../../src/core/events/PRE_STEP_EVENT.js"),
READY: __webpack_require__(/*! ./READY_EVENT */ "../../../src/core/events/READY_EVENT.js"),
RESUME: __webpack_require__(/*! ./RESUME_EVENT */ "../../../src/core/events/RESUME_EVENT.js"),
STEP: __webpack_require__(/*! ./STEP_EVENT */ "../../../src/core/events/STEP_EVENT.js"),
VISIBLE: __webpack_require__(/*! ./VISIBLE_EVENT */ "../../../src/core/events/VISIBLE_EVENT.js")
};
/***/ }),
/***/ "../../../src/data/DataManager.js":
/*!**************************************************!*\
!*** D:/wamp/www/phaser/src/data/DataManager.js ***!
\**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = __webpack_require__(/*! ../utils/Class */ "../../../src/utils/Class.js");
var Events = __webpack_require__(/*! ./events */ "../../../src/data/events/index.js");
/**
* @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.<string, *>}
* @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.<string, *>}
* @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.<string, *>} 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.<string, *>} 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
*
* @param {(string|object)} key - The key to set the value for. Or an object or 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 DataManager object.
*/
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|object)} key - The key to increase the value for.
* @param {*} [data] - The value to increase for the given key.
*
* @return {Phaser.Data.DataManager} This DataManager object.
*/
inc: function (key, data)
{
if (this._frozen)
{
return this;
}
if (data === undefined)
{
data = 1;
}
var value = this.get(key);
if (value === undefined)
{
value = 0;
}
this.set(key, (value + data));
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|object)} key - The key to toggle the value for.
*
* @return {Phaser.Data.DataManager} This DataManager object.
*/
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 DataManager object.
*/
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 DataManager object.
*/
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.<string, *>} data - The data to merge.
* @param {boolean} [overwrite=true] - Whether to overwrite existing data. Defaults to true.
*
* @return {this} This DataManager object.
*/
merge: function (data, overwrite)
{
if (overwrite === undefined) { overwrite = true; }
// Merge data from another component into this one
for (var key in data)
{
if (data.hasOwnProperty(key) && (overwrite || (!overwrite && !this.has(key))))
{
this.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 DataManager object.
*/
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 DataManager object.
*/
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 DataManager object.
*/
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 DataManager object.
*/
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;
}
},