2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
|
|
|
* @copyright 2018 Photon Storm Ltd.
|
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
2018-01-16 19:49:13 +00:00
|
|
|
var Class = require('../utils/Class');
|
2018-01-20 04:47:03 +00:00
|
|
|
var CONST = require('./const');
|
2018-01-18 05:20:57 +00:00
|
|
|
var GetPhysicsPlugins = require('./GetPhysicsPlugins');
|
|
|
|
var GetScenePlugins = require('./GetScenePlugins');
|
2018-02-12 23:03:48 +00:00
|
|
|
var Plugins = require('../plugins');
|
2018-01-17 03:41:58 +00:00
|
|
|
var Settings = require('./Settings');
|
2018-01-10 16:29:37 +00:00
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
|
|
|
* @classdesc
|
|
|
|
* The Scene Systems class.
|
|
|
|
*
|
|
|
|
* This class is available from within a Scene under the property `sys`.
|
|
|
|
* It is responsible for managing all of the plugins a Scene has running, including the display list, and
|
|
|
|
* handling the update step and renderer. It also contains references to global systems belonging to Game.
|
|
|
|
*
|
|
|
|
* @class Systems
|
|
|
|
* @memberOf Phaser.Scenes
|
|
|
|
* @constructor
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.Scene} scene - The Scene that owns this Systems instance.
|
2018-03-21 13:41:17 +00:00
|
|
|
* @param {(string|SettingsConfig)} config - Scene specific configuration settings.
|
2018-02-12 15:18:31 +00:00
|
|
|
*/
|
2017-07-04 12:58:45 +00:00
|
|
|
var Systems = new Class({
|
2016-11-29 15:25:14 +00:00
|
|
|
|
2017-07-04 12:58:45 +00:00
|
|
|
initialize:
|
2016-12-06 16:49:29 +00:00
|
|
|
|
2017-07-14 13:30:20 +00:00
|
|
|
function Systems (scene, config)
|
2017-07-04 12:58:45 +00:00
|
|
|
{
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Scenes.Systems#scene
|
|
|
|
* @type {Phaser.Scene}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-07-14 13:30:20 +00:00
|
|
|
this.scene = scene;
|
2017-07-04 12:58:45 +00:00
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Scenes.Systems#game
|
|
|
|
* @type {Phaser.Game}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-12 17:09:09 +00:00
|
|
|
this.game;
|
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Scenes.Systems#config
|
2018-03-21 13:41:17 +00:00
|
|
|
* @type {(string|SettingsConfig)}
|
2018-02-12 15:18:31 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-07-04 12:58:45 +00:00
|
|
|
this.config = config;
|
2018-01-12 17:09:09 +00:00
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Scenes.Systems#settings
|
2018-03-21 13:41:17 +00:00
|
|
|
* @type {SettingsObject}
|
2018-02-12 15:18:31 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-07-04 12:58:45 +00:00
|
|
|
this.settings = Settings.create(config);
|
2017-04-04 22:59:02 +00:00
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
|
|
|
* A handy reference to the Scene canvas / context.
|
|
|
|
*
|
|
|
|
* @name Phaser.Scenes.Systems#canvas
|
|
|
|
* @type {HTMLCanvasElement}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-07-04 12:58:45 +00:00
|
|
|
this.canvas;
|
2018-02-12 15:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Scenes.Systems#context
|
|
|
|
* @type {CanvasRenderingContext2D}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-07-04 12:58:45 +00:00
|
|
|
this.context;
|
2017-04-04 22:59:02 +00:00
|
|
|
|
2018-01-18 05:20:57 +00:00
|
|
|
// Global Systems - these are single-instance global managers that belong to Game
|
2017-01-26 04:06:10 +00:00
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Scenes.Systems#anims
|
|
|
|
* @type {Phaser.Animations.AnimationManager}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-07-04 12:58:45 +00:00
|
|
|
this.anims;
|
2018-02-12 15:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Scenes.Systems#cache
|
|
|
|
* @type {Phaser.Cache.CacheManager}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-07-04 12:58:45 +00:00
|
|
|
this.cache;
|
2018-02-12 15:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Scenes.Systems#plugins
|
2018-03-28 14:39:57 +00:00
|
|
|
* @type {Phaser.Boot.PluginManager}
|
2018-02-12 15:18:31 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-18 16:48:25 +00:00
|
|
|
this.plugins;
|
2018-02-12 15:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Scenes.Systems#registry
|
2018-03-19 11:25:46 +00:00
|
|
|
* @type {Phaser.Data.DataManager}
|
2018-02-12 15:18:31 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-07-04 12:58:45 +00:00
|
|
|
this.registry;
|
2018-02-12 15:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Scenes.Systems#sound
|
|
|
|
* @type {Phaser.Sound.BaseSoundManager}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-11 14:48:43 +00:00
|
|
|
this.sound;
|
2018-02-12 15:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Scenes.Systems#textures
|
|
|
|
* @type {Phaser.Textures.TextureManager}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-07-04 12:58:45 +00:00
|
|
|
this.textures;
|
2016-11-29 15:25:14 +00:00
|
|
|
|
2018-01-18 05:20:57 +00:00
|
|
|
// Core Plugins - these are non-optional Scene plugins, needed by lots of the other systems
|
2018-01-12 17:09:09 +00:00
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Scenes.Systems#add
|
|
|
|
* @type {Phaser.GameObjects.GameObjectFactory}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-16 02:08:22 +00:00
|
|
|
this.add;
|
2018-02-12 15:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Scenes.Systems#cameras
|
|
|
|
* @type {Phaser.Cameras.Scene2D.CameraManager}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-07-04 12:58:45 +00:00
|
|
|
this.cameras;
|
2018-02-12 15:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Scenes.Systems#displayList
|
2018-04-03 14:08:48 +00:00
|
|
|
* @type {Phaser.GameObjects.DisplayList}
|
2018-02-12 15:18:31 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-08-15 22:36:46 +00:00
|
|
|
this.displayList;
|
2018-02-12 15:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Scenes.Systems#events
|
2018-03-29 12:12:07 +00:00
|
|
|
* @type {Phaser.Events.EventEmitter}
|
2018-02-12 15:18:31 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-07-04 12:58:45 +00:00
|
|
|
this.events;
|
2018-02-12 15:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Scenes.Systems#make
|
|
|
|
* @type {Phaser.GameObjects.GameObjectCreator}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-16 02:08:22 +00:00
|
|
|
this.make;
|
2018-02-12 15:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Scenes.Systems#scenePlugin
|
|
|
|
* @type {Phaser.Scenes.ScenePlugin}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-18 05:20:57 +00:00
|
|
|
this.scenePlugin;
|
2018-02-12 15:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Scenes.Systems#updateList
|
2018-03-19 00:59:59 +00:00
|
|
|
* @type {Phaser.GameObjects.UpdateList}
|
2018-02-12 15:18:31 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-12 17:09:09 +00:00
|
|
|
this.updateList;
|
2017-07-04 12:58:45 +00:00
|
|
|
},
|
2016-11-29 15:25:14 +00:00
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
2018-04-13 16:12:17 +00:00
|
|
|
* This method is called only once by the Scene Manager when the Scene is instantiated.
|
|
|
|
* It is responsible for setting up all of the Scene plugins and references.
|
|
|
|
* It should never be called directly.
|
2018-02-12 15:18:31 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.Scenes.Systems#init
|
2018-04-13 16:12:17 +00:00
|
|
|
* @protected
|
2018-02-12 15:18:31 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-04-13 16:12:17 +00:00
|
|
|
* @param {Phaser.Game} game - A reference to the Phaser Game instance.
|
2018-02-12 15:18:31 +00:00
|
|
|
*/
|
2017-01-25 17:10:19 +00:00
|
|
|
init: function (game)
|
2016-11-29 15:25:14 +00:00
|
|
|
{
|
2018-01-20 16:22:40 +00:00
|
|
|
this.settings.status = CONST.INIT;
|
|
|
|
|
2017-01-25 17:10:19 +00:00
|
|
|
this.game = game;
|
2016-11-29 15:25:14 +00:00
|
|
|
|
2018-01-20 04:47:03 +00:00
|
|
|
this.canvas = game.canvas;
|
|
|
|
this.context = game.context;
|
|
|
|
|
2018-01-18 16:48:25 +00:00
|
|
|
var pluginManager = game.plugins;
|
2017-02-12 13:19:55 +00:00
|
|
|
|
2018-01-18 16:48:25 +00:00
|
|
|
this.plugins = pluginManager;
|
2017-01-26 04:06:10 +00:00
|
|
|
|
2018-02-12 23:03:48 +00:00
|
|
|
pluginManager.installGlobal(this, Plugins.Global);
|
2018-01-10 16:29:37 +00:00
|
|
|
|
2018-02-12 23:03:48 +00:00
|
|
|
pluginManager.installLocal(this, Plugins.CoreScene);
|
2018-01-18 16:48:25 +00:00
|
|
|
|
|
|
|
pluginManager.installLocal(this, GetScenePlugins(this));
|
|
|
|
|
|
|
|
pluginManager.installLocal(this, GetPhysicsPlugins(this));
|
2018-01-16 02:08:22 +00:00
|
|
|
|
|
|
|
this.events.emit('boot', this);
|
2018-01-18 13:59:32 +00:00
|
|
|
|
|
|
|
this.settings.isBooted = true;
|
|
|
|
},
|
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
2018-04-13 16:12:17 +00:00
|
|
|
* Called by a plugin, it tells the System to install the plugin locally.
|
2018-02-12 15:18:31 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.Scenes.Systems#install
|
|
|
|
* @private
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {array} plugin - An array of plugins to install into this Scene.
|
|
|
|
*/
|
2018-01-18 13:59:32 +00:00
|
|
|
install: function (plugin)
|
|
|
|
{
|
|
|
|
if (!Array.isArray(plugin))
|
|
|
|
{
|
|
|
|
plugin = [ plugin ];
|
|
|
|
}
|
|
|
|
|
2018-01-18 16:48:25 +00:00
|
|
|
this.plugins.installLocal(this, plugin);
|
2018-01-16 02:08:22 +00:00
|
|
|
},
|
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
2018-04-13 16:12:17 +00:00
|
|
|
* A single game step. Called automatically by the Scene Manager as a result of a Request Animation
|
|
|
|
* Frame or Set Timeout call to the main Game instance.
|
2018-02-12 15:18:31 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.Scenes.Systems#step
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {number} time - [description]
|
|
|
|
* @param {number} delta - [description]
|
|
|
|
*/
|
2017-04-27 16:03:19 +00:00
|
|
|
step: function (time, delta)
|
2017-04-27 02:11:56 +00:00
|
|
|
{
|
2018-01-16 22:28:29 +00:00
|
|
|
this.events.emit('preupdate', time, delta);
|
2017-06-30 03:09:19 +00:00
|
|
|
|
2018-01-16 02:08:22 +00:00
|
|
|
this.events.emit('update', time, delta);
|
|
|
|
|
2017-07-14 13:30:20 +00:00
|
|
|
this.scene.update.call(this.scene, time, delta);
|
2017-11-08 17:18:10 +00:00
|
|
|
|
2018-01-16 02:08:22 +00:00
|
|
|
this.events.emit('postupdate', time, delta);
|
2017-04-27 02:11:56 +00:00
|
|
|
},
|
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
2018-04-13 16:12:17 +00:00
|
|
|
* Called automatically by the Scene Manager. Instructs the Scene to render itself via
|
|
|
|
* its Camera Manager to the renderer given.
|
2018-02-12 15:18:31 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.Scenes.Systems#render
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-03-20 15:12:42 +00:00
|
|
|
* @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description]
|
2018-02-12 15:18:31 +00:00
|
|
|
*/
|
2018-01-20 04:47:03 +00:00
|
|
|
render: function (renderer)
|
2017-01-30 23:58:29 +00:00
|
|
|
{
|
2018-01-11 13:59:06 +00:00
|
|
|
var displayList = this.displayList;
|
2017-12-15 04:07:32 +00:00
|
|
|
|
2018-02-12 16:59:57 +00:00
|
|
|
displayList.depthSort();
|
2017-04-04 22:59:02 +00:00
|
|
|
|
2018-01-20 04:47:03 +00:00
|
|
|
this.cameras.render(renderer, displayList);
|
|
|
|
|
|
|
|
this.events.emit('render', renderer);
|
2017-04-04 22:59:02 +00:00
|
|
|
},
|
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
|
|
|
* Force a sort of the display list on the next render.
|
|
|
|
*
|
|
|
|
* @method Phaser.Scenes.Systems#queueDepthSort
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-07-20 11:48:35 +00:00
|
|
|
queueDepthSort: function ()
|
2017-07-07 17:13:26 +00:00
|
|
|
{
|
2018-01-11 13:59:06 +00:00
|
|
|
this.displayList.queueDepthSort();
|
2017-07-07 17:13:26 +00:00
|
|
|
},
|
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
|
|
|
* Immediately sorts the display list if the flag is set.
|
|
|
|
*
|
|
|
|
* @method Phaser.Scenes.Systems#depthSort
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-07-20 11:48:35 +00:00
|
|
|
depthSort: function ()
|
|
|
|
{
|
2018-01-11 13:59:06 +00:00
|
|
|
this.displayList.depthSort();
|
2017-06-30 02:31:31 +00:00
|
|
|
},
|
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
|
|
|
* Pause this Scene.
|
|
|
|
* A paused Scene still renders, it just doesn't run ANY of its update handlers or systems.
|
|
|
|
*
|
|
|
|
* @method Phaser.Scenes.Systems#pause
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {Phaser.Scenes.Systems} This Systems object.
|
|
|
|
*/
|
2017-06-30 02:31:31 +00:00
|
|
|
pause: function ()
|
|
|
|
{
|
2018-01-20 04:47:03 +00:00
|
|
|
if (this.settings.active)
|
|
|
|
{
|
2018-01-20 16:22:40 +00:00
|
|
|
this.settings.status = CONST.PAUSED;
|
|
|
|
|
2018-01-20 04:47:03 +00:00
|
|
|
this.settings.active = false;
|
2017-06-30 02:31:31 +00:00
|
|
|
|
2018-01-20 04:47:03 +00:00
|
|
|
this.events.emit('pause', this);
|
|
|
|
}
|
2018-02-12 15:18:31 +00:00
|
|
|
|
|
|
|
return this;
|
2017-06-30 02:31:31 +00:00
|
|
|
},
|
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
2018-04-13 16:12:17 +00:00
|
|
|
* Resume this Scene from a paused state.
|
2018-02-12 15:18:31 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.Scenes.Systems#resume
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {Phaser.Scenes.Systems} This Systems object.
|
|
|
|
*/
|
2017-06-30 02:31:31 +00:00
|
|
|
resume: function ()
|
|
|
|
{
|
2018-01-20 04:47:03 +00:00
|
|
|
if (!this.settings.active)
|
|
|
|
{
|
2018-01-20 16:22:40 +00:00
|
|
|
this.settings.status = CONST.RUNNING;
|
|
|
|
|
2018-01-20 04:47:03 +00:00
|
|
|
this.settings.active = true;
|
2017-06-30 02:31:31 +00:00
|
|
|
|
2018-01-20 04:47:03 +00:00
|
|
|
this.events.emit('resume', this);
|
|
|
|
}
|
2018-02-12 15:18:31 +00:00
|
|
|
|
|
|
|
return this;
|
2017-06-30 02:31:31 +00:00
|
|
|
},
|
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
|
|
|
* Send this Scene to sleep.
|
2018-03-19 00:59:59 +00:00
|
|
|
*
|
2018-02-12 15:18:31 +00:00
|
|
|
* A sleeping Scene doesn't run it's update step or render anything, but it also isn't destroyed,
|
|
|
|
* or have any of its systems or children removed, meaning it can be re-activated at any point.
|
|
|
|
*
|
|
|
|
* @method Phaser.Scenes.Systems#sleep
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {Phaser.Scenes.Systems} This Systems object.
|
|
|
|
*/
|
2017-06-30 02:31:31 +00:00
|
|
|
sleep: function ()
|
|
|
|
{
|
2018-01-20 16:22:40 +00:00
|
|
|
this.settings.status = CONST.SLEEPING;
|
|
|
|
|
2017-06-30 02:31:31 +00:00
|
|
|
this.settings.active = false;
|
|
|
|
this.settings.visible = false;
|
|
|
|
|
2018-01-17 03:41:58 +00:00
|
|
|
this.events.emit('sleep', this);
|
2018-02-12 15:18:31 +00:00
|
|
|
|
|
|
|
return this;
|
2017-06-30 02:31:31 +00:00
|
|
|
},
|
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
|
|
|
* Wake-up this Scene if it was previously asleep.
|
|
|
|
*
|
|
|
|
* @method Phaser.Scenes.Systems#wake
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {Phaser.Scenes.Systems} This Systems object.
|
|
|
|
*/
|
2017-06-30 02:31:31 +00:00
|
|
|
wake: function ()
|
|
|
|
{
|
2018-01-20 16:22:40 +00:00
|
|
|
this.settings.status = CONST.RUNNING;
|
|
|
|
|
2017-06-30 02:31:31 +00:00
|
|
|
this.settings.active = true;
|
|
|
|
this.settings.visible = true;
|
|
|
|
|
2018-01-17 03:41:58 +00:00
|
|
|
this.events.emit('wake', this);
|
2018-02-12 15:18:31 +00:00
|
|
|
|
|
|
|
return this;
|
2017-06-30 03:06:53 +00:00
|
|
|
},
|
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
|
|
|
* Is this Scene sleeping?
|
|
|
|
*
|
|
|
|
* @method Phaser.Scenes.Systems#isSleeping
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {boolean} [description]
|
|
|
|
*/
|
2018-01-20 04:47:03 +00:00
|
|
|
isSleeping: function ()
|
|
|
|
{
|
2018-01-20 16:22:40 +00:00
|
|
|
return (this.settings.status === CONST.SLEEPING);
|
2018-01-20 04:47:03 +00:00
|
|
|
},
|
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
|
|
|
* Is this Scene active?
|
|
|
|
*
|
|
|
|
* @method Phaser.Scenes.Systems#isActive
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {boolean} [description]
|
|
|
|
*/
|
2018-01-20 04:47:03 +00:00
|
|
|
isActive: function ()
|
|
|
|
{
|
2018-01-20 16:22:40 +00:00
|
|
|
return (this.settings.status === CONST.RUNNING);
|
2018-01-20 04:47:03 +00:00
|
|
|
},
|
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
|
|
|
* Is this Scene visible and rendering?
|
|
|
|
*
|
|
|
|
* @method Phaser.Scenes.Systems#isVisible
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {boolean} [description]
|
|
|
|
*/
|
2018-01-20 04:47:03 +00:00
|
|
|
isVisible: function ()
|
|
|
|
{
|
|
|
|
return this.settings.visible;
|
|
|
|
},
|
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
2018-04-13 16:12:17 +00:00
|
|
|
* Sets the visible state of this Scene.
|
|
|
|
* An invisible Scene will not render, but will still process updates.
|
2018-02-12 15:18:31 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.Scenes.Systems#setVisible
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {boolean} value - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Scenes.Systems} This Systems object.
|
|
|
|
*/
|
2018-01-20 04:47:03 +00:00
|
|
|
setVisible: function (value)
|
|
|
|
{
|
|
|
|
this.settings.visible = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
2018-04-13 16:12:17 +00:00
|
|
|
* Set the active state of this Scene.
|
|
|
|
* An active Scene will run its core update loop.
|
2018-02-12 15:18:31 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.Scenes.Systems#setActive
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-04-13 16:12:17 +00:00
|
|
|
* @param {boolean} value - If `true` the Scene will be resumed, if previously paused. If `false` it will be paused.
|
2018-02-12 15:18:31 +00:00
|
|
|
*
|
|
|
|
* @return {Phaser.Scenes.Systems} This Systems object.
|
|
|
|
*/
|
2018-01-20 04:47:03 +00:00
|
|
|
setActive: function (value)
|
2017-06-30 03:06:53 +00:00
|
|
|
{
|
2018-01-20 16:22:40 +00:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
return this.resume();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return this.pause();
|
|
|
|
}
|
2018-01-20 04:47:03 +00:00
|
|
|
},
|
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
|
|
|
* Start this Scene running and rendering.
|
2018-04-09 11:57:03 +00:00
|
|
|
* Called automatically by the SceneManager.
|
2018-02-12 15:18:31 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.Scenes.Systems#start
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-04-13 16:12:17 +00:00
|
|
|
* @param {object} data - Optional data object that may have been passed to this Scene from another.
|
2018-02-12 15:18:31 +00:00
|
|
|
*/
|
2018-01-20 04:47:03 +00:00
|
|
|
start: function (data)
|
|
|
|
{
|
2018-04-09 11:57:03 +00:00
|
|
|
if (data)
|
|
|
|
{
|
|
|
|
this.settings.data = data;
|
|
|
|
}
|
2018-01-20 16:22:40 +00:00
|
|
|
|
2018-04-09 11:57:03 +00:00
|
|
|
this.settings.status = CONST.START;
|
2017-06-30 03:06:53 +00:00
|
|
|
|
|
|
|
this.settings.active = true;
|
|
|
|
this.settings.visible = true;
|
2018-01-17 03:41:58 +00:00
|
|
|
|
|
|
|
this.events.emit('start', this);
|
2017-06-30 02:31:31 +00:00
|
|
|
},
|
|
|
|
|
2018-02-28 17:18:40 +00:00
|
|
|
/**
|
|
|
|
* Called automatically by the SceneManager if the Game resizes.
|
|
|
|
* Dispatches an event you can respond to in your game code.
|
|
|
|
*
|
|
|
|
* @method Phaser.Scenes.Systems#resize
|
|
|
|
* @since 3.2.0
|
|
|
|
*
|
|
|
|
* @param {number} width - The new width of the game.
|
|
|
|
* @param {number} height - The new height of the game.
|
|
|
|
*/
|
|
|
|
resize: function (width, height)
|
|
|
|
{
|
|
|
|
this.events.emit('resize', width, height);
|
|
|
|
},
|
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
|
|
|
* Shutdown this Scene and send a shutdown event to all of its systems.
|
2018-04-13 16:12:17 +00:00
|
|
|
* A Scene that has been shutdown will not run its update loop or render, but it does
|
|
|
|
* not destroy any of its plugins or references. It is put into hibernation for later use.
|
|
|
|
* If you don't ever plan to use this Scene again, then it should be destroyed instead
|
|
|
|
* to free-up resources.
|
2018-02-12 15:18:31 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.Scenes.Systems#shutdown
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-06-30 02:31:31 +00:00
|
|
|
shutdown: function ()
|
|
|
|
{
|
2018-01-20 16:22:40 +00:00
|
|
|
this.settings.status = CONST.SHUTDOWN;
|
|
|
|
|
2017-06-30 02:31:31 +00:00
|
|
|
this.settings.active = false;
|
2017-06-30 03:06:53 +00:00
|
|
|
this.settings.visible = false;
|
2017-06-30 02:31:31 +00:00
|
|
|
|
2018-01-16 02:08:22 +00:00
|
|
|
this.events.emit('shutdown', this);
|
2017-06-30 02:31:31 +00:00
|
|
|
},
|
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
|
|
|
* Destroy this Scene and send a destroy event all of its systems.
|
2018-04-13 16:12:17 +00:00
|
|
|
* A destroyed Scene cannot be restarted.
|
|
|
|
* You should not call this directly, instead use `SceneManager.remove`.
|
2018-02-12 15:18:31 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.Scenes.Systems#destroy
|
2018-04-13 16:12:17 +00:00
|
|
|
* @private
|
2018-02-12 15:18:31 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-06-30 02:31:31 +00:00
|
|
|
destroy: function ()
|
|
|
|
{
|
2018-01-20 16:22:40 +00:00
|
|
|
this.settings.status = CONST.DESTROYED;
|
|
|
|
|
2018-01-31 03:38:10 +00:00
|
|
|
this.settings.active = false;
|
|
|
|
this.settings.visible = false;
|
|
|
|
|
2018-01-16 02:08:22 +00:00
|
|
|
this.events.emit('destroy', this);
|
2018-04-13 16:12:17 +00:00
|
|
|
|
|
|
|
this.events.removeAllListeners();
|
|
|
|
|
|
|
|
var props = [ 'scene', 'game', 'anims', 'cache', 'plugins', 'registry', 'sound', 'textures', 'add', 'camera', 'displayList', 'events', 'make', 'scenePlugin', 'updateList' ];
|
|
|
|
|
|
|
|
for (var i = 0; i < props.length; i++)
|
|
|
|
{
|
|
|
|
this[props[i]] = null;
|
|
|
|
}
|
2017-02-08 00:08:09 +00:00
|
|
|
}
|
2016-11-29 15:25:14 +00:00
|
|
|
|
2017-07-04 12:58:45 +00:00
|
|
|
});
|
2017-06-30 02:31:31 +00:00
|
|
|
|
2016-11-29 15:25:14 +00:00
|
|
|
module.exports = Systems;
|