Skip to content

Commit 8c55844

Browse files
authored
Merge pull request phaserjs#4469 from samme/docs/scenes
Docs for scene config and optional scene methods
2 parents c38ebe1 + f9797d0 commit 8c55844

6 files changed

Lines changed: 29 additions & 12 deletions

File tree

src/core/Config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var ValueToColor = require('../display/color/ValueToColor');
1717

1818
/**
1919
* @classdesc
20-
* The active game configuration settings, parsed from a {@link GameConfig} object.
20+
* The active game configuration settings, parsed from a {@link Phaser.Core.Types.GameConfig} object.
2121
*
2222
* @class Config
2323
* @memberof Phaser.Core

src/core/typedefs/GameConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @property {HTMLCanvasElement} [canvas=null] - Provide your own Canvas element for Phaser to use instead of creating one.
1212
* @property {string} [canvasStyle=null] - CSS styles to apply to the game canvas instead of Phaser's default styles.
1313
* @property {CanvasRenderingContext2D} [context] - Provide your own Canvas Context for Phaser to use, instead of creating one.
14-
* @property {object} [scene=null] - A scene or scenes to add to the game. If several are given, the first is started; the remainder are started only if they have { active: true }.
14+
* @property {(Phaser.Scene|Phaser.Scene[]|Phaser.Scenes.Types.SettingsConfig|Phaser.Scenes.Types.SettingsConfig[]|Phaser.Scenes.Types.CreateSceneFromObjectConfig|Phaser.Scenes.Types.CreateSceneFromObjectConfig[]|function|function[])} [scene=null] - A scene or scenes to add to the game. If several are given, the first is started; the remainder are started only if they have `{ active: true }`. See the `sceneConfig` argument in {@link Phaser.Scenes.SceneManager#add}.
1515
* @property {string[]} [seed] - Seed for the random number generator.
1616
* @property {string} [title=''] - The title of the game. Shown in the browser console.
1717
* @property {string} [url='http://phaser.io'] - The URL of the game. Shown in the browser console.

src/scene/Scene.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,9 @@ var Scene = new Class({
269269

270270
/**
271271
* Should be overridden by your own Scenes.
272+
* This method is called once per game step while the scene is running.
272273
*
273274
* @method Phaser.Scene#update
274-
* @override
275275
* @since 3.0.0
276276
*
277277
* @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.
@@ -282,27 +282,33 @@ var Scene = new Class({
282282
}
283283

284284
/**
285-
* Should be overridden by your own Scenes.
285+
* Can be defined on your own Scenes.
286+
* This method is called by the Scene Manager when the scene starts, before `preload()` and `create()`.
286287
*
287288
* @method Phaser.Scene#init
288-
* @override
289289
* @since 3.0.0
290+
*
291+
* @param {object} data - Any data passed via `ScenePlugin.add()` or `ScenePlugin.start()`. Same as Scene.settings.data.
290292
*/
291293

292294
/**
293-
* Should be overridden by your own Scenes.
295+
* Can be defined on your own Scenes. Use it to load assets.
296+
* This method is called by the Scene Manager, after `init()` and before `create()`, only if the Scene has a LoaderPlugin.
297+
* After this method completes, if the LoaderPlugin's queue isn't empty, the LoaderPlugin will start automatically.
294298
*
295299
* @method Phaser.Scene#preload
296-
* @override
297300
* @since 3.0.0
298301
*/
299302

300303
/**
301-
* Should be overridden by your own Scenes.
304+
* Can be defined on your own Scenes. Use it to create your game objects.
305+
* This method is called by the Scene Manager when the scene starts, after `init()` and `preload()`.
306+
* If the LoaderPlugin started after `preload()`, then this method is called only after loading is complete.
302307
*
303308
* @method Phaser.Scene#create
304-
* @override
305309
* @since 3.0.0
310+
*
311+
* @param {object} data - Any data passed via `ScenePlugin.add()` or `ScenePlugin.start()`. Same as Scene.settings.data.
306312
*/
307313

308314
});

src/scene/SceneManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ var SceneManager = new Class({
312312
* @since 3.0.0
313313
*
314314
* @param {string} key - A unique key used to reference the Scene, i.e. `MainMenu` or `Level1`.
315-
* @param {(Phaser.Scene|Phaser.Scenes.Types.SettingsConfig|function)} sceneConfig - The config for the Scene
315+
* @param {(Phaser.Scene|Phaser.Scenes.Types.SettingsConfig|Phaser.Scenes.Types.CreateSceneFromObjectConfig|function)} sceneConfig - The config for the Scene
316316
* @param {boolean} [autoStart=false] - If `true` the Scene will be started immediately after being added.
317317
* @param {object} [data] - Optional data object. This will be set as Scene.settings.data and passed to `Scene.init`.
318318
*
@@ -710,7 +710,7 @@ var SceneManager = new Class({
710710
* @since 3.0.0
711711
*
712712
* @param {string} key - The key of the Scene.
713-
* @param {(string|Phaser.Scenes.Types.SettingsConfig)} sceneConfig - The Scene config.
713+
* @param {(string|Phaser.Scenes.Types.SettingsConfig|Phaser.Scenes.Types.CreateSceneFromObjectConfig)} sceneConfig - The Scene config.
714714
*
715715
* @return {Phaser.Scene} The created Scene.
716716
*/

src/scene/ScenePlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ var ScenePlugin = new Class({
430430
* @since 3.0.0
431431
*
432432
* @param {string} key - The Scene key.
433-
* @param {(Phaser.Scene|Phaser.Scenes.Types.SettingsConfig|function)} sceneConfig - The config for the Scene.
433+
* @param {(Phaser.Scene|Phaser.Scenes.Types.SettingsConfig|Phaser.Scenes.Types.CreateSceneFromObjectConfig|function)} sceneConfig - The config for the Scene.
434434
* @param {boolean} autoStart - Whether to start the Scene after it's added.
435435
* @param {object} [data] - Optional data object. This will be set as Scene.settings.data and passed to `Scene.init`.
436436
*
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @typedef {object} Phaser.Scenes.Types.CreateSceneFromObjectConfig
3+
* @since 3.17.0
4+
*
5+
* @property {function} [init] - See {@link Phaser.Scene#init}.
6+
* @property {function} [preload] - See See {@link Phaser.Scene#preload}.
7+
* @property {function} [create] - See {@link Phaser.Scene#create}.
8+
* @property {function} [update] - See {@link Phaser.Scene#update}.
9+
* @property {any} [extend] - Any additional properties, which will be copied to the Scene after it's created (except `data` or `sys`).
10+
* @property {any} [extend.data] - Any values, which will be merged into the Scene's Data Manager store.
11+
*/

0 commit comments

Comments
 (0)