diff --git a/src/animations/Animation.js b/src/animations/Animation.js index df7633d4d..1bcf2e2c2 100644 --- a/src/animations/Animation.js +++ b/src/animations/Animation.js @@ -214,8 +214,8 @@ var Animation = new Class({ */ this.paused = false; - this.manager.on('pauseall', this.pause, this); - this.manager.on('resumeall', this.resume, this); + this.manager.on(Events.PAUSE_ALL, this.pause, this); + this.manager.on(Events.RESUME_ALL, this.resume, this); }, /** @@ -915,8 +915,8 @@ var Animation = new Class({ { this.removeAllListeners(); - this.manager.off('pauseall', this.pause, this); - this.manager.off('resumeall', this.resume, this); + this.manager.off(Events.PAUSE_ALL, this.pause, this); + this.manager.off(Events.RESUME_ALL, this.resume, this); this.manager.remove(this.key); diff --git a/src/animations/AnimationManager.js b/src/animations/AnimationManager.js index 9353d2829..4beb8aed8 100644 --- a/src/animations/AnimationManager.js +++ b/src/animations/AnimationManager.js @@ -9,6 +9,7 @@ var Class = require('../utils/Class'); var CustomMap = require('../structs/Map'); var EventEmitter = require('eventemitter3'); var Events = require('./events'); +var GameEvents = require('../core/events'); var GetValue = require('../utils/object/GetValue'); var Pad = require('../utils/string/Pad'); @@ -110,20 +111,21 @@ var AnimationManager = new Class({ */ this.name = 'AnimationManager'; - game.events.once('boot', this.boot, this); + 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('destroy', this.destroy, this); + this.game.events.once(GameEvents.DESTROY, this.destroy, this); }, /** diff --git a/src/cache/CacheManager.js b/src/cache/CacheManager.js index 3ad5e9c4c..8d18f9e26 100644 --- a/src/cache/CacheManager.js +++ b/src/cache/CacheManager.js @@ -6,6 +6,7 @@ var BaseCache = require('./BaseCache'); var Class = require('../utils/Class'); +var GameEvents = require('../core/events'); /** * @classdesc @@ -149,7 +150,7 @@ var CacheManager = new Class({ */ this.custom = {}; - this.game.events.once('destroy', this.destroy, this); + this.game.events.once(GameEvents.DESTROY, this.destroy, this); }, /** diff --git a/src/cameras/2d/CameraManager.js b/src/cameras/2d/CameraManager.js index 9b7be8604..06f5ffaea 100644 --- a/src/cameras/2d/CameraManager.js +++ b/src/cameras/2d/CameraManager.js @@ -9,6 +9,7 @@ var Class = require('../../utils/Class'); var GetFastValue = require('../../utils/object/GetFastValue'); var PluginCache = require('../../plugins/PluginCache'); var RectangleContains = require('../../geom/rectangle/Contains'); +var SceneEvents = require('../../scene/events'); /** * @typedef {object} InputJSONCameraObject @@ -134,8 +135,8 @@ var CameraManager = new Class({ */ this.main; - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); + scene.sys.events.on(SceneEvents.START, this.start, this); }, /** @@ -144,6 +145,7 @@ var CameraManager = new Class({ * * @method Phaser.Cameras.Scene2D.CameraManager#boot * @private + * @listens Phaser.Scenes.Events#DESTROY * @since 3.5.1 */ boot: function () @@ -163,7 +165,7 @@ var CameraManager = new Class({ this.main = this.cameras[0]; - this.systems.events.once('destroy', this.destroy, this); + this.systems.events.once(SceneEvents.DESTROY, this.destroy, this); }, /** @@ -173,6 +175,8 @@ var CameraManager = new Class({ * * @method Phaser.Cameras.Scene2D.CameraManager#start * @private + * @listens Phaser.Scenes.Events#UPDATE + * @listens Phaser.Scenes.Events#SHUTDOWN * @since 3.5.0 */ start: function () @@ -197,8 +201,8 @@ var CameraManager = new Class({ var eventEmitter = this.systems.events; - eventEmitter.on('update', this.update, this); - eventEmitter.once('shutdown', this.shutdown, this); + eventEmitter.on(SceneEvents.UPDATE, this.update, this); + eventEmitter.once(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -685,8 +689,8 @@ var CameraManager = new Class({ var eventEmitter = this.systems.events; - eventEmitter.off('update', this.update, this); - eventEmitter.off('shutdown', this.shutdown, this); + eventEmitter.off(SceneEvents.UPDATE, this.update, this); + eventEmitter.off(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -701,7 +705,7 @@ var CameraManager = new Class({ { this.shutdown(); - this.scene.sys.events.off('start', this.start, this); + this.scene.sys.events.off(SceneEvents.START, this.start, this); this.scene = null; this.systems = null; diff --git a/src/core/Game.js b/src/core/Game.js index 136dd13a1..70efba097 100644 --- a/src/core/Game.js +++ b/src/core/Game.js @@ -352,6 +352,8 @@ var Game = new Class({ */ boot: function () { + console.log('g boot'); + if (!PluginCache.hasCore('EventEmitter')) { console.warn('Aborting. Core Plugins missing.'); @@ -375,11 +377,11 @@ var Game = new Class({ AddToDOM(this.canvas, this.config.parent); - this.events.emit(Events.BOOT); - // 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.events.once(TextureEvents.READY, this.texturesReady, this); + this.textures.once(TextureEvents.READY, this.texturesReady, this); + + this.events.emit(Events.BOOT); }, /** @@ -427,10 +429,10 @@ var Game = new Class({ var eventEmitter = this.events; - eventEmitter.on('hidden', this.onHidden, this); - eventEmitter.on('visible', this.onVisible, this); - eventEmitter.on('blur', this.onBlur, this); - eventEmitter.on('focus', this.onFocus, this); + 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); }, /** diff --git a/src/data/DataManagerPlugin.js b/src/data/DataManagerPlugin.js index 3c3b73b2a..089f46f02 100644 --- a/src/data/DataManagerPlugin.js +++ b/src/data/DataManagerPlugin.js @@ -7,6 +7,7 @@ var Class = require('../utils/Class'); var DataManager = require('./DataManager'); var PluginCache = require('../plugins/PluginCache'); +var SceneEvents = require('../scene/events'); /** * @classdesc @@ -50,8 +51,8 @@ var DataManagerPlugin = new Class({ */ this.systems = scene.sys; - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); + scene.sys.events.on(SceneEvents.START, this.start, this); }, /** @@ -66,7 +67,7 @@ var DataManagerPlugin = new Class({ { this.events = this.systems.events; - this.events.once('destroy', this.destroy, this); + this.events.once(SceneEvents.DESTROY, this.destroy, this); }, /** @@ -80,7 +81,7 @@ var DataManagerPlugin = new Class({ */ start: function () { - this.events.once('shutdown', this.shutdown, this); + this.events.once(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -93,7 +94,7 @@ var DataManagerPlugin = new Class({ */ shutdown: function () { - this.systems.events.off('shutdown', this.shutdown, this); + this.systems.events.off(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -107,7 +108,7 @@ var DataManagerPlugin = new Class({ { DataManager.prototype.destroy.call(this); - this.events.off('start', this.start, this); + this.events.off(SceneEvents.START, this.start, this); this.scene = null; this.systems = null; diff --git a/src/gameobjects/DisplayList.js b/src/gameobjects/DisplayList.js index 76bf801c3..b3d9b5e7f 100644 --- a/src/gameobjects/DisplayList.js +++ b/src/gameobjects/DisplayList.js @@ -7,6 +7,7 @@ var Class = require('../utils/Class'); var List = require('../structs/List'); var PluginCache = require('../plugins/PluginCache'); +var SceneEvents = require('../scene/events'); var StableSort = require('../utils/array/StableSort'); /** @@ -63,8 +64,8 @@ var DisplayList = new Class({ */ this.systems = scene.sys; - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); + scene.sys.events.on(SceneEvents.START, this.start, this); }, /** @@ -77,7 +78,7 @@ var DisplayList = new Class({ */ boot: function () { - this.systems.events.once('destroy', this.destroy, this); + this.systems.events.once(SceneEvents.DESTROY, this.destroy, this); }, /** @@ -91,7 +92,7 @@ var DisplayList = new Class({ */ start: function () { - this.systems.events.once('shutdown', this.shutdown, this); + this.systems.events.once(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -170,7 +171,7 @@ var DisplayList = new Class({ this.list.length = 0; - this.systems.events.off('shutdown', this.shutdown, this); + this.systems.events.off(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -185,7 +186,7 @@ var DisplayList = new Class({ { this.shutdown(); - this.scene.sys.events.off('start', this.start, this); + this.scene.sys.events.off(SceneEvents.START, this.start, this); this.scene = null; this.systems = null; diff --git a/src/gameobjects/GameObjectCreator.js b/src/gameobjects/GameObjectCreator.js index 208ae4d82..9b7f82db5 100644 --- a/src/gameobjects/GameObjectCreator.js +++ b/src/gameobjects/GameObjectCreator.js @@ -6,6 +6,7 @@ var Class = require('../utils/Class'); var PluginCache = require('../plugins/PluginCache'); +var SceneEvents = require('../scene/events'); /** * @classdesc @@ -69,8 +70,8 @@ var GameObjectCreator = new Class({ */ this.updateList; - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); + scene.sys.events.on(SceneEvents.START, this.start, this); }, /** @@ -86,7 +87,7 @@ var GameObjectCreator = new Class({ this.displayList = this.systems.displayList; this.updateList = this.systems.updateList; - this.systems.events.once('destroy', this.destroy, this); + this.systems.events.once(SceneEvents.DESTROY, this.destroy, this); }, /** @@ -100,7 +101,7 @@ var GameObjectCreator = new Class({ */ start: function () { - this.systems.events.once('shutdown', this.shutdown, this); + this.systems.events.once(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -113,7 +114,7 @@ var GameObjectCreator = new Class({ */ shutdown: function () { - this.systems.events.off('shutdown', this.shutdown, this); + this.systems.events.off(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -128,7 +129,7 @@ var GameObjectCreator = new Class({ { this.shutdown(); - this.scene.sys.events.off('start', this.start, this); + this.scene.sys.events.off(SceneEvents.START, this.start, this); this.scene = null; this.systems = null; diff --git a/src/gameobjects/GameObjectFactory.js b/src/gameobjects/GameObjectFactory.js index 45bc9b47b..7ca86e0c5 100644 --- a/src/gameobjects/GameObjectFactory.js +++ b/src/gameobjects/GameObjectFactory.js @@ -6,6 +6,7 @@ var Class = require('../utils/Class'); var PluginCache = require('../plugins/PluginCache'); +var SceneEvents = require('../scene/events'); /** * @classdesc @@ -68,8 +69,8 @@ var GameObjectFactory = new Class({ */ this.updateList; - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); + scene.sys.events.on(SceneEvents.START, this.start, this); }, /** @@ -85,7 +86,7 @@ var GameObjectFactory = new Class({ this.displayList = this.systems.displayList; this.updateList = this.systems.updateList; - this.systems.events.once('destroy', this.destroy, this); + this.systems.events.once(SceneEvents.DESTROY, this.destroy, this); }, /** @@ -99,7 +100,7 @@ var GameObjectFactory = new Class({ */ start: function () { - this.systems.events.once('shutdown', this.shutdown, this); + this.systems.events.once(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -140,7 +141,7 @@ var GameObjectFactory = new Class({ */ shutdown: function () { - this.systems.events.off('shutdown', this.shutdown, this); + this.systems.events.off(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -155,7 +156,7 @@ var GameObjectFactory = new Class({ { this.shutdown(); - this.scene.sys.events.off('start', this.start, this); + this.scene.sys.events.off(SceneEvents.START, this.start, this); this.scene = null; this.systems = null; diff --git a/src/gameobjects/UpdateList.js b/src/gameobjects/UpdateList.js index e180838d2..84ef1c3c9 100644 --- a/src/gameobjects/UpdateList.js +++ b/src/gameobjects/UpdateList.js @@ -6,6 +6,7 @@ var Class = require('../utils/Class'); var PluginCache = require('../plugins/PluginCache'); +var SceneEvents = require('../scene/events'); /** * @classdesc @@ -79,8 +80,8 @@ var UpdateList = new Class({ */ this._pendingRemoval = []; - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); + scene.sys.events.on(SceneEvents.START, this.start, this); }, /** @@ -93,7 +94,7 @@ var UpdateList = new Class({ */ boot: function () { - this.systems.events.once('destroy', this.destroy, this); + this.systems.events.once(SceneEvents.DESTROY, this.destroy, this); }, /** @@ -109,9 +110,9 @@ var UpdateList = new Class({ { var eventEmitter = this.systems.events; - eventEmitter.on('preupdate', this.preUpdate, this); - eventEmitter.on('update', this.update, this); - eventEmitter.once('shutdown', this.shutdown, this); + eventEmitter.on(SceneEvents.PRE_UPDATE, this.preUpdate, this); + eventEmitter.on(SceneEvents.UPDATE, this.update, this); + eventEmitter.once(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -281,9 +282,9 @@ var UpdateList = new Class({ var eventEmitter = this.systems.events; - eventEmitter.off('preupdate', this.preUpdate, this); - eventEmitter.off('update', this.update, this); - eventEmitter.off('shutdown', this.shutdown, this); + eventEmitter.off(SceneEvents.PRE_UPDATE, this.preUpdate, this); + eventEmitter.off(SceneEvents.UPDATE, this.update, this); + eventEmitter.off(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -297,7 +298,7 @@ var UpdateList = new Class({ { this.shutdown(); - this.scene.sys.events.off('start', this.start, this); + this.scene.sys.events.off(SceneEvents.START, this.start, this); this.scene = null; this.systems = null; diff --git a/src/gameobjects/components/Animation.js b/src/gameobjects/components/Animation.js index db4be2e5a..a35db11ca 100644 --- a/src/gameobjects/components/Animation.js +++ b/src/gameobjects/components/Animation.js @@ -45,7 +45,7 @@ var Animation = new Class({ */ this.animationManager = parent.scene.sys.anims; - this.animationManager.once('remove', this.remove, this); + this.animationManager.once(Events.REMOVE_ANIMATION, this.remove, this); /** * Is an animation currently playing or not? @@ -1147,7 +1147,7 @@ var Animation = new Class({ */ destroy: function () { - this.animationManager.off('remove', this.remove, this); + this.animationManager.off(Events.REMOVE_ANIMATION, this.remove, this); this.animationManager = null; this.parent = null; diff --git a/src/gameobjects/lights/LightsPlugin.js b/src/gameobjects/lights/LightsPlugin.js index 23c70d091..090823f1d 100644 --- a/src/gameobjects/lights/LightsPlugin.js +++ b/src/gameobjects/lights/LightsPlugin.js @@ -7,6 +7,7 @@ var Class = require('../../utils/Class'); var LightsManager = require('./LightsManager'); var PluginCache = require('../../plugins/PluginCache'); +var SceneEvents = require('../../scene/events'); /** * @classdesc @@ -66,7 +67,7 @@ var LightsPlugin = new Class({ if (!scene.sys.settings.isBooted) { - scene.sys.events.once('boot', this.boot, this); + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); } LightsManager.call(this); @@ -82,8 +83,8 @@ var LightsPlugin = new Class({ { var eventEmitter = this.systems.events; - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); + eventEmitter.on(SceneEvents.SHUTDOWN, this.shutdown, this); + eventEmitter.on(SceneEvents.DESTROY, this.destroy, this); }, /** diff --git a/src/input/InputPlugin.js b/src/input/InputPlugin.js index dc5fb1d0a..f3f9b821c 100644 --- a/src/input/InputPlugin.js +++ b/src/input/InputPlugin.js @@ -20,6 +20,7 @@ var IsPlainObject = require('../utils/object/IsPlainObject'); var PluginCache = require('../plugins/PluginCache'); var Rectangle = require('../geom/rectangle/Rectangle'); var RectangleContains = require('../geom/rectangle/Contains'); +var SceneEvents = require('../scene/events'); var Triangle = require('../geom/triangle/Triangle'); var TriangleContains = require('../geom/triangle/Contains'); @@ -355,8 +356,8 @@ var InputPlugin = new Class({ */ this._validTypes = [ 'onDown', 'onUp', 'onOver', 'onOut', 'onMove', 'onDragStart', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragLeave', 'onDragOver', 'onDrop' ]; - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); + scene.sys.events.on(SceneEvents.START, this.start, this); }, /** @@ -374,7 +375,7 @@ var InputPlugin = new Class({ this.displayList = this.systems.displayList; - this.systems.events.once('destroy', this.destroy, this); + this.systems.events.once(SceneEvents.DESTROY, this.destroy, this); // Registered input plugins listen for this this.pluginEvents.emit(Events.BOOT); @@ -394,13 +395,13 @@ var InputPlugin = new Class({ { var eventEmitter = this.systems.events; - eventEmitter.on('transitionstart', this.transitionIn, this); - eventEmitter.on('transitionout', this.transitionOut, this); - eventEmitter.on('transitioncomplete', this.transitionComplete, this); - eventEmitter.on('preupdate', this.preUpdate, this); - eventEmitter.on('update', this.update, this); + eventEmitter.on(SceneEvents.TRANSITION_START, this.transitionIn, this); + eventEmitter.on(SceneEvents.TRANSITION_OUT, this.transitionOut, this); + eventEmitter.on(SceneEvents.TRANSITION_COMPLETE, this.transitionComplete, this); + eventEmitter.on(SceneEvents.PRE_UPDATE, this.preUpdate, this); + eventEmitter.on(SceneEvents.UPDATE, this.update, this); - eventEmitter.once('shutdown', this.shutdown, this); + eventEmitter.once(SceneEvents.SHUTDOWN, this.shutdown, this); this.enabled = true; @@ -2321,13 +2322,13 @@ var InputPlugin = new Class({ var eventEmitter = this.systems.events; - eventEmitter.off('transitionstart', this.transitionIn, this); - eventEmitter.off('transitionout', this.transitionOut, this); - eventEmitter.off('transitioncomplete', this.transitionComplete, this); + eventEmitter.off(SceneEvents.TRANSITION_START, this.transitionIn, this); + eventEmitter.off(SceneEvents.TRANSITION_OUT, this.transitionOut, this); + eventEmitter.off(SceneEvents.TRANSITION_COMPLETE, this.transitionComplete, this); - eventEmitter.off('preupdate', this.preUpdate, this); - eventEmitter.off('update', this.update, this); - eventEmitter.off('shutdown', this.shutdown, this); + eventEmitter.off(SceneEvents.PRE_UPDATE, this.preUpdate, this); + eventEmitter.off(SceneEvents.UPDATE, this.update, this); + eventEmitter.off(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -2348,7 +2349,7 @@ var InputPlugin = new Class({ this.pluginEvents.removeAllListeners(); - this.scene.sys.events.off('start', this.start, this); + this.scene.sys.events.off(SceneEvents.START, this.start, this); this.scene = null; this.cameras = null; diff --git a/src/input/gamepad/GamepadPlugin.js b/src/input/gamepad/GamepadPlugin.js index 4509a7455..73fbaa1f1 100644 --- a/src/input/gamepad/GamepadPlugin.js +++ b/src/input/gamepad/GamepadPlugin.js @@ -10,6 +10,7 @@ var Events = require('./events'); var Gamepad = require('./Gamepad'); var GetValue = require('../../utils/object/GetValue'); var InputPluginCache = require('../InputPluginCache'); +var InputEvents = require('../events'); /** * @typedef {object} Pad @@ -189,8 +190,8 @@ var GamepadPlugin = new Class({ */ this._pad4; - sceneInputPlugin.pluginEvents.once('boot', this.boot, this); - sceneInputPlugin.pluginEvents.on('start', this.start, this); + sceneInputPlugin.pluginEvents.once(InputEvents.BOOT, this.boot, this); + sceneInputPlugin.pluginEvents.on(InputEvents.START, this.start, this); }, /** @@ -210,7 +211,7 @@ var GamepadPlugin = new Class({ this.enabled = GetValue(settings, 'gamepad', config.inputGamepad) && game.device.input.gamepads; this.target = GetValue(settings, 'gamepad.target', config.inputGamepadEventTarget); - this.sceneInputPlugin.pluginEvents.once('destroy', this.destroy, this); + this.sceneInputPlugin.pluginEvents.once(InputEvents.DESTROY, this.destroy, this); }, /** @@ -229,7 +230,7 @@ var GamepadPlugin = new Class({ this.startListeners(); } - this.sceneInputPlugin.pluginEvents.once('shutdown', this.shutdown, this); + this.sceneInputPlugin.pluginEvents.once(InputEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -283,7 +284,7 @@ var GamepadPlugin = new Class({ // until more browsers support this // Finally, listen for an update event from the Input Plugin - this.sceneInputPlugin.pluginEvents.on('update', this.update, this); + this.sceneInputPlugin.pluginEvents.on(InputEvents.UPDATE, this.update, this); }, /** @@ -299,7 +300,7 @@ var GamepadPlugin = new Class({ this.target.removeEventListener('gamepadconnected', this.onGamepadHandler); this.target.removeEventListener('gamepaddisconnected', this.onGamepadHandler); - this.sceneInputPlugin.pluginEvents.off('update', this.update); + this.sceneInputPlugin.pluginEvents.off(InputEvents.UPDATE, this.update); }, /** diff --git a/src/input/keyboard/KeyboardManager.js b/src/input/keyboard/KeyboardManager.js index e5970526d..9ab21f6a2 100644 --- a/src/input/keyboard/KeyboardManager.js +++ b/src/input/keyboard/KeyboardManager.js @@ -422,7 +422,7 @@ var KeyboardManager = new Class({ this.queue = []; - this.manager.game.events.off('poststep', this.postUpdate, this); + this.manager.game.events.off(GameEvents.POST_RENDER, this.postUpdate, this); this.target = null; this.enabled = false; diff --git a/src/input/keyboard/KeyboardPlugin.js b/src/input/keyboard/KeyboardPlugin.js index a04b7cc1e..82781ceda 100644 --- a/src/input/keyboard/KeyboardPlugin.js +++ b/src/input/keyboard/KeyboardPlugin.js @@ -8,6 +8,7 @@ var Class = require('../../utils/Class'); var EventEmitter = require('eventemitter3'); var Events = require('./events'); var GetValue = require('../../utils/object/GetValue'); +var InputEvents = require('../events'); var InputPluginCache = require('../InputPluginCache'); var Key = require('./keys/Key'); var KeyCodes = require('./keys/KeyCodes'); @@ -145,8 +146,8 @@ var KeyboardPlugin = new Class({ */ this.time = 0; - sceneInputPlugin.pluginEvents.once('boot', this.boot, this); - sceneInputPlugin.pluginEvents.on('start', this.start, this); + sceneInputPlugin.pluginEvents.once(InputEvents.BOOT, this.boot, this); + sceneInputPlugin.pluginEvents.on(InputEvents.START, this.start, this); }, /** @@ -170,7 +171,7 @@ var KeyboardPlugin = new Class({ this.addCaptures(captures); } - this.sceneInputPlugin.pluginEvents.once('destroy', this.destroy, this); + this.sceneInputPlugin.pluginEvents.once(InputEvents.DESTROY, this.destroy, this); }, /** @@ -186,7 +187,7 @@ var KeyboardPlugin = new Class({ { this.startListeners(); - this.sceneInputPlugin.pluginEvents.once('shutdown', this.shutdown, this); + this.sceneInputPlugin.pluginEvents.once(InputEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -212,7 +213,7 @@ var KeyboardPlugin = new Class({ */ startListeners: function () { - this.sceneInputPlugin.pluginEvents.on('update', this.update, this); + this.sceneInputPlugin.pluginEvents.on(InputEvents.UPDATE, this.update, this); }, /** @@ -225,7 +226,7 @@ var KeyboardPlugin = new Class({ */ stopListeners: function () { - this.sceneInputPlugin.pluginEvents.off('update', this.update); + this.sceneInputPlugin.pluginEvents.off(InputEvents.UPDATE, this.update); }, /** diff --git a/src/input/keyboard/combo/KeyCombo.js b/src/input/keyboard/combo/KeyCombo.js index 7a7f0547e..e913e3e9d 100644 --- a/src/input/keyboard/combo/KeyCombo.js +++ b/src/input/keyboard/combo/KeyCombo.js @@ -261,7 +261,7 @@ var KeyCombo = new Class({ */ this.onKeyDown = onKeyDownHandler; - this.manager.on(Events.ANY_KEY_DOWN, onKeyDownHandler); + this.manager.on(Events.ANY_KEY_DOWN, this.onKeyDown); }, /** @@ -292,7 +292,7 @@ var KeyCombo = new Class({ this.enabled = false; this.keyCodes = []; - this.manager.off('keydown', this.onKeyDown); + this.manager.off(Events.ANY_KEY_DOWN, this.onKeyDown); this.manager = null; } diff --git a/src/loader/LoaderPlugin.js b/src/loader/LoaderPlugin.js index fa864e7a0..ccc921358 100644 --- a/src/loader/LoaderPlugin.js +++ b/src/loader/LoaderPlugin.js @@ -12,6 +12,7 @@ var Events = require('./events'); var FileTypesManager = require('./FileTypesManager'); var GetFastValue = require('../utils/object/GetFastValue'); var PluginCache = require('../plugins/PluginCache'); +var SceneEvents = require('../scene/events'); var XHRSettings = require('./XHRSettings'); /** @@ -312,8 +313,8 @@ var LoaderPlugin = new Class({ */ this.state = CONST.LOADER_IDLE; - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.pluginStart, this); + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); + scene.sys.events.on(SceneEvents.START, this.pluginStart, this); }, /** @@ -326,7 +327,7 @@ var LoaderPlugin = new Class({ */ boot: function () { - this.systems.events.once('destroy', this.destroy, this); + this.systems.events.once(SceneEvents.DESTROY, this.destroy, this); }, /** @@ -340,7 +341,7 @@ var LoaderPlugin = new Class({ */ pluginStart: function () { - this.systems.events.once('shutdown', this.shutdown, this); + this.systems.events.once(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -705,7 +706,7 @@ var LoaderPlugin = new Class({ this.checkLoadQueue(); - this.systems.events.on('update', this.update, this); + this.systems.events.on(SceneEvents.UPDATE, this.update, this); } }, @@ -906,7 +907,7 @@ var LoaderPlugin = new Class({ this.state = CONST.LOADER_COMPLETE; - this.systems.events.off('update', this.update, this); + this.systems.events.off(SceneEvents.UPDATE, this.update, this); // Call 'destroy' on each file ready for deletion this._deleteQueue.iterateLocal('destroy'); @@ -1021,8 +1022,8 @@ var LoaderPlugin = new Class({ this.state = CONST.LOADER_SHUTDOWN; - this.systems.events.off('update', this.update, this); - this.systems.events.off('shutdown', this.shutdown, this); + this.systems.events.off(SceneEvents.UPDATE, this.update, this); + this.systems.events.off(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -1039,8 +1040,8 @@ var LoaderPlugin = new Class({ this.state = CONST.LOADER_DESTROYED; - this.systems.events.off('update', this.update, this); - this.systems.events.off('start', this.pluginStart, this); + this.systems.events.off(SceneEvents.UPDATE, this.update, this); + this.systems.events.off(SceneEvents.START, this.pluginStart, this); this.list = null; this.inflight = null; diff --git a/src/loader/filetypes/AnimationJSONFile.js b/src/loader/filetypes/AnimationJSONFile.js index 728af7bc6..29fd67158 100644 --- a/src/loader/filetypes/AnimationJSONFile.js +++ b/src/loader/filetypes/AnimationJSONFile.js @@ -7,6 +7,7 @@ var Class = require('../../utils/Class'); var FileTypesManager = require('../FileTypesManager'); var JSONFile = require('./JSONFile.js'); +var LoaderEvents = require('../events'); /** * @classdesc @@ -54,7 +55,7 @@ var AnimationJSONFile = new Class({ onProcess: function () { // We need to hook into this event: - this.loader.once('loadcomplete', this.onLoadComplete, this); + this.loader.once(LoaderEvents.POST_PROCESS, this.onLoadComplete, this); // But the rest is the same as a normal JSON file JSONFile.prototype.onProcess.call(this); diff --git a/src/physics/arcade/ArcadePhysics.js b/src/physics/arcade/ArcadePhysics.js index 310c53020..c5f2ff7fa 100644 --- a/src/physics/arcade/ArcadePhysics.js +++ b/src/physics/arcade/ArcadePhysics.js @@ -12,6 +12,7 @@ var Factory = require('./Factory'); var GetFastValue = require('../../utils/object/GetFastValue'); var Merge = require('../../utils/object/Merge'); var PluginCache = require('../../plugins/PluginCache'); +var SceneEvents = require('../../scene/events'); var Vector2 = require('../../math/Vector2'); var World = require('./World'); @@ -80,8 +81,8 @@ var ArcadePhysics = new Class({ */ this.add; - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); + scene.sys.events.on(SceneEvents.START, this.start, this); }, /** @@ -97,7 +98,7 @@ var ArcadePhysics = new Class({ this.world = new World(this.scene, this.config); this.add = new Factory(this.world); - this.systems.events.once('destroy', this.destroy, this); + this.systems.events.once(SceneEvents.DESTROY, this.destroy, this); }, /** @@ -119,9 +120,9 @@ var ArcadePhysics = new Class({ var eventEmitter = this.systems.events; - eventEmitter.on('update', this.world.update, this.world); - eventEmitter.on('postupdate', this.world.postUpdate, this.world); - eventEmitter.once('shutdown', this.shutdown, this); + eventEmitter.on(SceneEvents.UPDATE, this.world.update, this.world); + eventEmitter.on(SceneEvents.POST_UPDATE, this.world.postUpdate, this.world); + eventEmitter.once(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -468,9 +469,9 @@ var ArcadePhysics = new Class({ var eventEmitter = this.systems.events; - eventEmitter.off('update', this.world.update, this.world); - eventEmitter.off('postupdate', this.world.postUpdate, this.world); - eventEmitter.off('shutdown', this.shutdown, this); + eventEmitter.off(SceneEvents.UPDATE, this.world.update, this.world); + eventEmitter.off(SceneEvents.POST_UPDATE, this.world.postUpdate, this.world); + eventEmitter.off(SceneEvents.SHUTDOWN, this.shutdown, this); this.add.destroy(); this.world.destroy(); @@ -490,7 +491,7 @@ var ArcadePhysics = new Class({ { this.shutdown(); - this.scene.sys.events.off('start', this.start, this); + this.scene.sys.events.off(SceneEvents.START, this.start, this); this.scene = null; this.systems = null; diff --git a/src/physics/impact/ImpactPhysics.js b/src/physics/impact/ImpactPhysics.js index 5f79fcd52..68dcc731a 100644 --- a/src/physics/impact/ImpactPhysics.js +++ b/src/physics/impact/ImpactPhysics.js @@ -9,6 +9,7 @@ var Factory = require('./Factory'); var GetFastValue = require('../../utils/object/GetFastValue'); var Merge = require('../../utils/object/Merge'); var PluginCache = require('../../plugins/PluginCache'); +var SceneEvents = require('../../scene/events'); var World = require('./World'); /** @@ -73,8 +74,8 @@ var ImpactPhysics = new Class({ */ this.add; - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); + scene.sys.events.on(SceneEvents.START, this.start, this); }, /** @@ -90,7 +91,7 @@ var ImpactPhysics = new Class({ this.world = new World(this.scene, this.config); this.add = new Factory(this.world); - this.systems.events.once('destroy', this.destroy, this); + this.systems.events.once(SceneEvents.DESTROY, this.destroy, this); }, /** @@ -112,8 +113,8 @@ var ImpactPhysics = new Class({ var eventEmitter = this.systems.events; - eventEmitter.on('update', this.world.update, this.world); - eventEmitter.once('shutdown', this.shutdown, this); + eventEmitter.on(SceneEvents.UPDATE, this.world.update, this.world); + eventEmitter.once(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -175,8 +176,8 @@ var ImpactPhysics = new Class({ { var eventEmitter = this.systems.events; - eventEmitter.off('update', this.world.update, this.world); - eventEmitter.off('shutdown', this.shutdown, this); + eventEmitter.off(SceneEvents.UPDATE, this.world.update, this.world); + eventEmitter.off(SceneEvents.SHUTDOWN, this.shutdown, this); this.add.destroy(); this.world.destroy(); @@ -197,7 +198,7 @@ var ImpactPhysics = new Class({ { this.shutdown(); - this.scene.sys.events.off('start', this.start, this); + this.scene.sys.events.off(SceneEvents.START, this.start, this); this.scene = null; this.systems = null; diff --git a/src/physics/matter-js/MatterPhysics.js b/src/physics/matter-js/MatterPhysics.js index e415576ff..55b281721 100644 --- a/src/physics/matter-js/MatterPhysics.js +++ b/src/physics/matter-js/MatterPhysics.js @@ -14,6 +14,7 @@ var MatterWrap = require('./lib/plugins/MatterWrap'); var Merge = require('../../utils/object/Merge'); var Plugin = require('./lib/core/Plugin'); var PluginCache = require('../../plugins/PluginCache'); +var SceneEvents = require('../../scene/events'); var World = require('./World'); var Vertices = require('./lib/geometry/Vertices'); @@ -104,8 +105,8 @@ var MatterPhysics = new Class({ Plugin.use(MatterLib, MatterWrap); } - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); + scene.sys.events.on(SceneEvents.START, this.start, this); }, /** @@ -121,7 +122,7 @@ var MatterPhysics = new Class({ this.world = new World(this.scene, this.config); this.add = new Factory(this.world); - this.systems.events.once('destroy', this.destroy, this); + this.systems.events.once(SceneEvents.DESTROY, this.destroy, this); }, /** @@ -143,9 +144,9 @@ var MatterPhysics = new Class({ var eventEmitter = this.systems.events; - eventEmitter.on('update', this.world.update, this.world); - eventEmitter.on('postupdate', this.world.postUpdate, this.world); - eventEmitter.once('shutdown', this.shutdown, this); + eventEmitter.on(SceneEvents.UPDATE, this.world.update, this.world); + eventEmitter.on(SceneEvents.POST_UPDATE, this.world.postUpdate, this.world); + eventEmitter.once(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -305,9 +306,9 @@ var MatterPhysics = new Class({ { var eventEmitter = this.systems.events; - eventEmitter.off('update', this.world.update, this.world); - eventEmitter.off('postupdate', this.world.postUpdate, this.world); - eventEmitter.off('shutdown', this.shutdown, this); + eventEmitter.off(SceneEvents.UPDATE, this.world.update, this.world); + eventEmitter.off(SceneEvents.POST_UPDATE, this.world.postUpdate, this.world); + eventEmitter.off(SceneEvents.SHUTDOWN, this.shutdown, this); this.add.destroy(); this.world.destroy(); @@ -328,7 +329,7 @@ var MatterPhysics = new Class({ { this.shutdown(); - this.scene.sys.events.off('start', this.start, this); + this.scene.sys.events.off(SceneEvents.START, this.start, this); this.scene = null; this.systems = null; diff --git a/src/physics/matter-js/PointerConstraint.js b/src/physics/matter-js/PointerConstraint.js index d5d2f2b5d..336938c3d 100644 --- a/src/physics/matter-js/PointerConstraint.js +++ b/src/physics/matter-js/PointerConstraint.js @@ -9,7 +9,9 @@ var Class = require('../../utils/Class'); var Composite = require('./lib/body/Composite'); var Constraint = require('./lib/constraint/Constraint'); var Detector = require('./lib/collision/Detector'); +var Events = require('./events'); var GetFastValue = require('../../utils/object/GetFastValue'); +var InputEvents = require('../../input/events'); var Merge = require('../../utils/object/Merge'); var Sleeping = require('./lib/core/Sleeping'); var Vector2 = require('../../math/Vector2'); @@ -128,11 +130,10 @@ var PointerConstraint = new Class({ */ this.constraint = Constraint.create(Merge(options, defaults)); - this.world.on('beforeupdate', this.update, this); + this.world.on(Events.BEFORE_UPDATE, this.update, this); - scene.sys.input.on('pointerdown', this.onDown, this); - - scene.sys.input.on('pointerup', this.onUp, this); + scene.sys.input.on(InputEvents.POINTER_DOWN, this.onDown, this); + scene.sys.input.on(InputEvents.POINTER_UP, this.onUp, this); }, /** @@ -273,11 +274,10 @@ var PointerConstraint = new Class({ this.constraint = null; - this.world.off('beforeupdate', this.update); + this.world.off(Events.BEFORE_UPDATE, this.update); - this.scene.sys.input.off('pointerdown', this.onDown, this); - - this.scene.sys.input.off('pointerup', this.onUp, this); + this.scene.sys.input.off(InputEvents.POINTER_DOWN, this.onDown, this); + this.scene.sys.input.off(InputEvents.POINTER_UP, this.onUp, this); } }); diff --git a/src/plugins/PluginManager.js b/src/plugins/PluginManager.js index 279b34c06..fb5806ad7 100644 --- a/src/plugins/PluginManager.js +++ b/src/plugins/PluginManager.js @@ -5,6 +5,7 @@ */ var Class = require('../utils/Class'); +var GameEvents = require('../core/events'); var EventEmitter = require('eventemitter3'); var FileTypesManager = require('../loader/FileTypesManager'); var GameObjectCreator = require('../gameobjects/GameObjectCreator'); @@ -127,7 +128,7 @@ var PluginManager = new Class({ } else { - game.events.once('boot', this.boot, this); + game.events.once(GameEvents.BOOT, this.boot, this); } }, @@ -198,7 +199,7 @@ var PluginManager = new Class({ this._pendingGlobal = []; this._pendingScene = []; - this.game.events.once('destroy', this.destroy, this); + this.game.events.once(GameEvents.DESTROY, this.destroy, this); }, /** diff --git a/src/plugins/ScenePlugin.js b/src/plugins/ScenePlugin.js index 09b069510..afd3ffaef 100644 --- a/src/plugins/ScenePlugin.js +++ b/src/plugins/ScenePlugin.js @@ -6,6 +6,7 @@ var BasePlugin = require('./BasePlugin'); var Class = require('../utils/Class'); +var SceneEvents = require('../scene/events'); /** * @classdesc @@ -35,7 +36,7 @@ var ScenePlugin = new Class({ this.scene = scene; this.systems = scene.sys; - scene.sys.events.once('boot', this.boot, this); + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); }, /** diff --git a/src/renderer/webgl/WebGLRenderer.js b/src/renderer/webgl/WebGLRenderer.js index e36913c03..f1ade9529 100644 --- a/src/renderer/webgl/WebGLRenderer.js +++ b/src/renderer/webgl/WebGLRenderer.js @@ -11,6 +11,7 @@ var Class = require('../../utils/Class'); var CONST = require('../../const'); var IsSizePowerOfTwo = require('../../math/pow2/IsSizePowerOfTwo'); var SpliceOne = require('../../utils/array/SpliceOne'); +var TextureEvents = require('../../textures/events'); var TransformMatrix = require('../../gameobjects/components/TransformMatrix'); var Utils = require('./Utils'); var WebGLSnapshot = require('../snapshot/WebGLSnapshot'); @@ -488,13 +489,14 @@ var WebGLRenderer = new Class({ init: function (config) { var gl; + var game = this.game; var canvas = this.canvas; var clearColor = config.backgroundColor; // Did they provide their own context? - if (this.game.config.context) + if (game.config.context) { - gl = this.game.config.context; + gl = game.config.context; } else { @@ -511,7 +513,7 @@ var WebGLRenderer = new Class({ this.gl = gl; // Set it back into the Game, so developers can access it from there too - this.game.context = gl; + game.context = gl; for (var i = 0; i <= 27; i++) { @@ -575,13 +577,13 @@ var WebGLRenderer = new Class({ // Clear previous pipelines and reload default ones this.pipelines = {}; - this.addPipeline('TextureTintPipeline', new TextureTintPipeline({ game: this.game, renderer: this })); - this.addPipeline('BitmapMaskPipeline', new BitmapMaskPipeline({ game: this.game, renderer: this })); - this.addPipeline('Light2D', new ForwardDiffuseLightPipeline({ game: this.game, renderer: this, maxLights: config.maxLights })); + this.addPipeline('TextureTintPipeline', new TextureTintPipeline({ game: game, renderer: this })); + this.addPipeline('BitmapMaskPipeline', new BitmapMaskPipeline({ game: game, renderer: this })); + this.addPipeline('Light2D', new ForwardDiffuseLightPipeline({ game: game, renderer: this, maxLights: config.maxLights })); this.setBlendMode(CONST.BlendModes.NORMAL); - this.game.events.once('texturesready', this.boot, this); + game.textures.once(TextureEvents.READY, this.boot, this); return this; }, diff --git a/src/scene/SceneManager.js b/src/scene/SceneManager.js index 010f0da56..13507fe40 100644 --- a/src/scene/SceneManager.js +++ b/src/scene/SceneManager.js @@ -7,7 +7,9 @@ var Class = require('../utils/Class'); var CONST = require('./const'); var Events = require('./events'); +var GameEvents = require('../core/events'); var GetValue = require('../utils/object/GetValue'); +var LoaderEvents = require('../loader/events'); var NOOP = require('../utils/NOOP'); var Scene = require('./Scene'); var Systems = require('./Systems'); @@ -153,7 +155,7 @@ var SceneManager = new Class({ } } - game.events.once('ready', this.bootQueue, this); + game.events.once(GameEvents.READY, this.bootQueue, this); }, /** @@ -485,7 +487,7 @@ var SceneManager = new Class({ settings.status = CONST.LOADING; // Start the loader going as we have something in the queue - loader.once('complete', this.loadComplete, this); + loader.once(LoaderEvents.COMPLETE, this.loadComplete, this); loader.start(); } @@ -1113,7 +1115,7 @@ var SceneManager = new Class({ { scene.sys.settings.status = CONST.LOADING; - loader.once('complete', this.payloadComplete, this); + loader.once(LoaderEvents.COMPLETE, this.payloadComplete, this); loader.start(); diff --git a/src/scene/ScenePlugin.js b/src/scene/ScenePlugin.js index 4ad83e1cb..0c3479f8c 100644 --- a/src/scene/ScenePlugin.js +++ b/src/scene/ScenePlugin.js @@ -152,8 +152,8 @@ var ScenePlugin = new Class({ */ this._willRemove = false; - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.pluginStart, this); + scene.sys.events.once(Events.BOOT, this.boot, this); + scene.sys.events.on(Events.START, this.pluginStart, this); }, /** @@ -166,7 +166,7 @@ var ScenePlugin = new Class({ */ boot: function () { - this.systems.events.once('destroy', this.destroy, this); + this.systems.events.once(Events.DESTROY, this.destroy, this); }, /** @@ -182,7 +182,7 @@ var ScenePlugin = new Class({ { this._target = null; - this.systems.events.once('shutdown', this.shutdown, this); + this.systems.events.once(Events.SHUTDOWN, this.shutdown, this); }, /** @@ -338,7 +338,7 @@ var ScenePlugin = new Class({ this.systems.events.emit(Events.TRANSITION_OUT, target, duration); - this.systems.events.on('update', this.step, this); + this.systems.events.on(Events.UPDATE, this.step, this); return true; }, @@ -407,7 +407,7 @@ var ScenePlugin = new Class({ var targetSettings = this._target.sys.settings; // Stop the step - this.systems.events.off('update', this.step, this); + this.systems.events.off(Events.UPDATE, this.step, this); // Notify target scene targetSys.events.emit(Events.TRANSITION_COMPLETE, this.scene); @@ -950,9 +950,9 @@ var ScenePlugin = new Class({ { var eventEmitter = this.systems.events; - eventEmitter.off('shutdown', this.shutdown, this); - eventEmitter.off('postupdate', this.step, this); - eventEmitter.off('transitionout'); + eventEmitter.off(Events.SHUTDOWN, this.shutdown, this); + eventEmitter.off(Events.POST_UPDATE, this.step, this); + eventEmitter.off(Events.TRANSITION_OUT); }, /** @@ -967,7 +967,7 @@ var ScenePlugin = new Class({ { this.shutdown(); - this.scene.sys.events.off('start', this.start, this); + this.scene.sys.events.off(Events.START, this.start, this); this.scene = null; this.systems = null; diff --git a/src/scene/Systems.js b/src/scene/Systems.js index f2a4d4ee9..b937bba66 100644 --- a/src/scene/Systems.js +++ b/src/scene/Systems.js @@ -704,10 +704,10 @@ var Systems = new Class({ */ shutdown: function (data) { - this.events.off('transitioninit'); - this.events.off('transitionstart'); - this.events.off('transitioncomplete'); - this.events.off('transitionout'); + this.events.off(Events.TRANSITION_INIT); + this.events.off(Events.TRANSITION_START); + this.events.off(Events.TRANSITION_COMPLETE); + this.events.off(Events.TRANSITION_OUT); this.settings.status = CONST.SHUTDOWN; diff --git a/src/textures/TextureManager.js b/src/textures/TextureManager.js index 2ee9dabea..a127fb6e3 100644 --- a/src/textures/TextureManager.js +++ b/src/textures/TextureManager.js @@ -125,8 +125,8 @@ var TextureManager = new Class({ { this._pending = 2; - this.on('onload', this.updatePending, this); - this.on('onerror', this.updatePending, this); + this.on(Events.LOAD, this.updatePending, this); + this.on(Events.ERROR, this.updatePending, this); this.addBase64('__DEFAULT', this.game.config.defaultImage); this.addBase64('__MISSING', this.game.config.missingImage); @@ -147,10 +147,10 @@ var TextureManager = new Class({ if (this._pending === 0) { - this.off('onload'); - this.off('onerror'); + this.off(Events.LOAD); + this.off(Events.ERROR); - this.game.events.emit(GameEvents.TEXTURES_READY); + this.emit(Events.READY); } }, diff --git a/src/time/Clock.js b/src/time/Clock.js index 86879266a..4c316484b 100644 --- a/src/time/Clock.js +++ b/src/time/Clock.js @@ -6,6 +6,7 @@ var Class = require('../utils/Class'); var PluginCache = require('../plugins/PluginCache'); +var SceneEvents = require('../scene/events'); var TimerEvent = require('./TimerEvent'); /** @@ -114,8 +115,8 @@ var Clock = new Class({ */ this._pendingRemoval = []; - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); + scene.sys.events.on(SceneEvents.START, this.start, this); }, /** @@ -128,7 +129,7 @@ var Clock = new Class({ */ boot: function () { - this.systems.events.once('destroy', this.destroy, this); + this.systems.events.once(SceneEvents.DESTROY, this.destroy, this); }, /** @@ -144,9 +145,9 @@ var Clock = new Class({ { var eventEmitter = this.systems.events; - eventEmitter.on('preupdate', this.preUpdate, this); - eventEmitter.on('update', this.update, this); - eventEmitter.once('shutdown', this.shutdown, this); + eventEmitter.on(SceneEvents.PRE_UPDATE, this.preUpdate, this); + eventEmitter.on(SceneEvents.UPDATE, this.update, this); + eventEmitter.once(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -366,9 +367,9 @@ var Clock = new Class({ var eventEmitter = this.systems.events; - eventEmitter.off('preupdate', this.preUpdate, this); - eventEmitter.off('update', this.update, this); - eventEmitter.off('shutdown', this.shutdown, this); + eventEmitter.off(SceneEvents.PRE_UPDATE, this.preUpdate, this); + eventEmitter.off(SceneEvents.UPDATE, this.update, this); + eventEmitter.off(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -383,7 +384,7 @@ var Clock = new Class({ { this.shutdown(); - this.scene.sys.events.off('start', this.start, this); + this.scene.sys.events.off(SceneEvents.START, this.start, this); this.scene = null; this.systems = null; diff --git a/src/tweens/TweenManager.js b/src/tweens/TweenManager.js index 495af4489..026873476 100644 --- a/src/tweens/TweenManager.js +++ b/src/tweens/TweenManager.js @@ -7,6 +7,7 @@ var Class = require('../utils/Class'); var NumberTweenBuilder = require('./builders/NumberTweenBuilder'); var PluginCache = require('../plugins/PluginCache'); +var SceneEvents = require('../scene/events'); var TimelineBuilder = require('./builders/TimelineBuilder'); var TWEEN_CONST = require('./tween/const'); var TweenBuilder = require('./builders/TweenBuilder'); @@ -109,8 +110,8 @@ var TweenManager = new Class({ */ this._toProcess = 0; - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); + scene.sys.events.once(SceneEvents.BOOT, this.boot, this); + scene.sys.events.on(SceneEvents.START, this.start, this); }, /** @@ -123,7 +124,7 @@ var TweenManager = new Class({ */ boot: function () { - this.systems.events.once('destroy', this.destroy, this); + this.systems.events.once(SceneEvents.DESTROY, this.destroy, this); }, /** @@ -139,9 +140,9 @@ var TweenManager = new Class({ { var eventEmitter = this.systems.events; - eventEmitter.on('preupdate', this.preUpdate, this); - eventEmitter.on('update', this.update, this); - eventEmitter.once('shutdown', this.shutdown, this); + eventEmitter.on(SceneEvents.PRE_UPDATE, this.preUpdate, this); + eventEmitter.on(SceneEvents.UPDATE, this.update, this); + eventEmitter.once(SceneEvents.SHUTDOWN, this.shutdown, this); this.timeScale = 1; }, @@ -666,9 +667,9 @@ var TweenManager = new Class({ var eventEmitter = this.systems.events; - eventEmitter.off('preupdate', this.preUpdate, this); - eventEmitter.off('update', this.update, this); - eventEmitter.off('shutdown', this.shutdown, this); + eventEmitter.off(SceneEvents.PRE_UPDATE, this.preUpdate, this); + eventEmitter.off(SceneEvents.UPDATE, this.update, this); + eventEmitter.off(SceneEvents.SHUTDOWN, this.shutdown, this); }, /** @@ -682,7 +683,7 @@ var TweenManager = new Class({ { this.shutdown(); - this.scene.sys.events.off('start', this.start, this); + this.scene.sys.events.off(SceneEvents.START, this.start, this); this.scene = null; this.systems = null;