Skip to content

Commit 98578a6

Browse files
committed
Merge branch 'master' of https://github.com/photonstorm/phaser
2 parents f26f78f + a29aba0 commit 98578a6

10 files changed

Lines changed: 57 additions & 39 deletions

File tree

src/boot/Config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ var Config = new Class({
502502
*
503503
* plugins: {
504504
* global: [
505-
* { key: 'TestPlugin', plugin: TestPlugin, start: true },
505+
* { key: 'TestPlugin', plugin: TestPlugin, start: true, data: { msg: 'The plugin is alive' } },
506506
* ],
507507
* scene: [
508508
* { key: 'WireFramePlugin', plugin: WireFramePlugin, systemKey: 'wireFramePlugin', sceneKey: 'wireframe' }

src/gameobjects/GameObject.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ var GameObject = new Class({
126126
* A bitmask that controls if this Game Object is drawn by a Camera or not.
127127
* Not usually set directly, instead call `Camera.ignore`, however you can
128128
* set this property directly using the Camera.id property:
129-
*
129+
*
130130
* @example
131131
* this.cameraFilter |= camera.id
132132
*
@@ -234,12 +234,12 @@ var GameObject = new Class({
234234

235235
/**
236236
* Allows you to store a key value pair within this Game Objects Data Manager.
237-
*
237+
*
238238
* If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled
239239
* before setting the value.
240-
*
240+
*
241241
* If the key doesn't already exist in the Data Manager then it is created.
242-
*
242+
*
243243
* ```javascript
244244
* sprite.setData('name', 'Red Gem Stone');
245245
* ```
@@ -251,13 +251,13 @@ var GameObject = new Class({
251251
* ```
252252
*
253253
* To get a value back again you can call `getData`:
254-
*
254+
*
255255
* ```javascript
256256
* sprite.getData('gold');
257257
* ```
258-
*
258+
*
259259
* Or you can access the value directly via the `values` property, where it works like any other variable:
260-
*
260+
*
261261
* ```javascript
262262
* sprite.data.values.gold += 50;
263263
* ```
@@ -295,19 +295,19 @@ var GameObject = new Class({
295295
* Retrieves the value for the given key in this Game Objects Data Manager, or undefined if it doesn't exist.
296296
*
297297
* You can also access values via the `values` object. For example, if you had a key called `gold` you can do either:
298-
*
298+
*
299299
* ```javascript
300300
* sprite.getData('gold');
301301
* ```
302302
*
303303
* Or access the value directly:
304-
*
304+
*
305305
* ```javascript
306306
* sprite.data.values.gold;
307307
* ```
308308
*
309309
* You can also pass in an array of keys, in which case an array of values will be returned:
310-
*
310+
*
311311
* ```javascript
312312
* sprite.getData([ 'gold', 'armor', 'health' ]);
313313
* ```
@@ -416,6 +416,8 @@ var GameObject = new Class({
416416
*
417417
* @method Phaser.GameObjects.GameObject#update
418418
* @since 3.0.0
419+
*
420+
* @param {...*} [args] - args
419421
*/
420422
update: function ()
421423
{
@@ -440,7 +442,7 @@ var GameObject = new Class({
440442
*
441443
* @method Phaser.GameObjects.GameObject#willRender
442444
* @since 3.0.0
443-
*
445+
*
444446
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to check against this Game Object.
445447
*
446448
* @return {boolean} True if the Game Object should be rendered, otherwise false.

src/gameobjects/sprite/SpriteCreator.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ var GameObjectCreator = require('../GameObjectCreator');
1010
var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
1111
var Sprite = require('./Sprite');
1212

13+
/**
14+
* @typedef {object} SpriteConfig
15+
* @extends GameObjectConfig
16+
*
17+
* @property {string} [key] - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
18+
* @property {(number|string)} [frame] - An optional frame from the Texture this Game Object is rendering with.
19+
*/
20+
1321
/**
1422
* Creates a new Sprite Game Object and returns it.
1523
*
@@ -18,7 +26,7 @@ var Sprite = require('./Sprite');
1826
* @method Phaser.GameObjects.GameObjectCreator#sprite
1927
* @since 3.0.0
2028
*
21-
* @param {object} config - The configuration object this Game Object will use to create itself.
29+
* @param {SpriteConfig} config - The configuration object this Game Object will use to create itself.
2230
* @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object.
2331
*
2432
* @return {Phaser.GameObjects.Sprite} The Game Object that was created.

src/plugins/BasePlugin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ var BasePlugin = new Class({
8080
*
8181
* @method Phaser.Plugins.BasePlugin#init
8282
* @since 3.8.0
83+
*
84+
* @param {?any} [data] - A value specified by the user, if any, from the `data` property of the plugin's configuration object (if started at game boot) or passed in the PluginManager's `install` method (if started manually).
8385
*/
8486
init: function ()
8587
{

src/plugins/PluginCache.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ PluginCache.register = function (key, plugin, mapping, custom)
6161
* @param {string} key - A reference used to get this plugin from the plugin cache.
6262
* @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated.
6363
* @param {string} mapping - If this plugin is to be injected into the Scene Systems, this is the property key map used.
64+
* @param {?any} data - A value to be passed to the plugin's `init` method.
6465
*/
65-
PluginCache.registerCustom = function (key, plugin, mapping)
66+
PluginCache.registerCustom = function (key, plugin, mapping, data)
6667
{
67-
customPlugins[key] = { plugin: plugin, mapping: mapping };
68+
customPlugins[key] = { plugin: plugin, mapping: mapping, data: data };
6869
};
6970

7071
/**

src/plugins/PluginManager.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ var PluginManager = new Class({
146146
var plugin;
147147
var start;
148148
var mapping;
149+
var data;
149150
var config = this.game.config;
150151

151152
// Any plugins to install?
@@ -158,16 +159,17 @@ var PluginManager = new Class({
158159
{
159160
entry = list[i];
160161

161-
// { key: 'TestPlugin', plugin: TestPlugin, start: true, mapping: 'test' }
162+
// { key: 'TestPlugin', plugin: TestPlugin, start: true, mapping: 'test', data: { msg: 'The plugin is alive' } }
162163

163164
key = GetFastValue(entry, 'key', null);
164165
plugin = GetFastValue(entry, 'plugin', null);
165166
start = GetFastValue(entry, 'start', false);
166167
mapping = GetFastValue(entry, 'mapping', null);
168+
data = GetFastValue(entry, 'data', null);
167169

168170
if (key && plugin)
169171
{
170-
this.install(key, plugin, start, mapping);
172+
this.install(key, plugin, start, mapping, data);
171173
}
172174
}
173175

@@ -399,11 +401,13 @@ var PluginManager = new Class({
399401
* @param {function} plugin - The plugin code. This should be the non-instantiated version.
400402
* @param {boolean} [start=false] - Automatically start the plugin running? This is always `true` if you provide a mapping value.
401403
* @param {string} [mapping] - If this plugin is injected into the Phaser.Scene class, this is the property key to use.
404+
* @param {any} [data] - A value passed to the plugin's `init` method.
402405
*/
403-
install: function (key, plugin, start, mapping)
406+
install: function (key, plugin, start, mapping, data)
404407
{
405408
if (start === undefined) { start = false; }
406409
if (mapping === undefined) { mapping = null; }
410+
if (data === undefined) { data = null; }
407411

408412
if (typeof plugin !== 'function')
409413
{
@@ -424,12 +428,12 @@ var PluginManager = new Class({
424428

425429
if (!this.game.isBooted)
426430
{
427-
this._pendingGlobal.push({ key: key, plugin: plugin, start: start, mapping: mapping });
431+
this._pendingGlobal.push({ key: key, plugin: plugin, start: start, mapping: mapping, data: data });
428432
}
429433
else
430434
{
431435
// Add it to the plugin store
432-
PluginCache.registerCustom(key, plugin, mapping);
436+
PluginCache.registerCustom(key, plugin, mapping, data);
433437

434438
if (start)
435439
{
@@ -568,12 +572,13 @@ var PluginManager = new Class({
568572
key: runAs,
569573
plugin: instance,
570574
active: true,
571-
mapping: entry.mapping
575+
mapping: entry.mapping,
576+
data: entry.data
572577
};
573578

574579
this.plugins.push(entry);
575580

576-
instance.init();
581+
instance.init(entry.data);
577582
instance.start();
578583
}
579584

src/tilemaps/Tilemap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ var Tilemap = new Class({
508508
* @param {(integer|string)} id - Either the id (object), gid (tile object) or name (object or
509509
* tile object) from Tiled. Ids are unique in Tiled, but a gid is shared by all tile objects
510510
* with the same graphic. The same name can be used on multiple objects.
511-
* @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e.
511+
* @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e.
512512
* scene.make.sprite).
513513
* @param {Phaser.Scene} [scene=the scene the map is within] - The Scene to create the Sprites within.
514514
*
@@ -599,7 +599,7 @@ var Tilemap = new Class({
599599
* @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted
600600
* tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a
601601
* one-to-one mapping with the indexes array.
602-
* @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e.
602+
* @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e.
603603
* scene.make.sprite).
604604
* @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within.
605605
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY

src/tilemaps/components/CreateFromTiles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var ReplaceByIndex = require('./ReplaceByIndex');
2323
* @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted
2424
* tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a
2525
* one-to-one mapping with the indexes array.
26-
* @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e.
26+
* @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e.
2727
* scene.make.sprite).
2828
* @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within.
2929
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY

src/tilemaps/dynamiclayer/DynamicTilemapLayer.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ var DynamicTilemapLayer = new Class({
134134
/**
135135
* You can control if the Cameras should cull tiles before rendering them or not.
136136
* By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer.
137-
*
137+
*
138138
* However, there are some instances when you may wish to disable this, and toggling this flag allows
139139
* you to do so. Also see `setSkipCull` for a chainable method that does the same thing.
140140
*
@@ -166,7 +166,7 @@ var DynamicTilemapLayer = new Class({
166166

167167
/**
168168
* The amount of extra tiles to add into the cull rectangle when calculating its horizontal size.
169-
*
169+
*
170170
* See the method `setCullPadding` for more details.
171171
*
172172
* @name Phaser.Tilemaps.DynamicTilemapLayer#cullPaddingX
@@ -178,7 +178,7 @@ var DynamicTilemapLayer = new Class({
178178

179179
/**
180180
* The amount of extra tiles to add into the cull rectangle when calculating its vertical size.
181-
*
181+
*
182182
* See the method `setCullPadding` for more details.
183183
*
184184
* @name Phaser.Tilemaps.DynamicTilemapLayer#cullPaddingY
@@ -190,15 +190,15 @@ var DynamicTilemapLayer = new Class({
190190

191191
/**
192192
* The callback that is invoked when the tiles are culled.
193-
*
193+
*
194194
* By default it will call `TilemapComponents.CullTiles` but you can override this to call any function you like.
195-
*
195+
*
196196
* It will be sent 3 arguments:
197-
*
197+
*
198198
* 1) The Phaser.Tilemaps.LayerData object for this Layer
199199
* 2) The Camera that is culling the layer. You can check its `dirty` property to see if it has changed since the last cull.
200200
* 3) A reference to the `culledTiles` array, which should be used to store the tiles you want rendered.
201-
*
201+
*
202202
* See the `TilemapComponents.CullTiles` source code for details on implementing your own culling system.
203203
*
204204
* @name Phaser.Tilemaps.DynamicTilemapLayer#cullCallback
@@ -270,7 +270,7 @@ var DynamicTilemapLayer = new Class({
270270
* @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted
271271
* tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a
272272
* one-to-one mapping with the indexes array.
273-
* @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e.
273+
* @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e.
274274
* scene.make.sprite).
275275
* @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within.
276276
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY
@@ -822,9 +822,9 @@ var DynamicTilemapLayer = new Class({
822822
/**
823823
* You can control if the Cameras should cull tiles before rendering them or not.
824824
* By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer.
825-
*
825+
*
826826
* However, there are some instances when you may wish to disable this.
827-
*
827+
*
828828
* @method Phaser.Tilemaps.DynamicTilemapLayer#setSkipCull
829829
* @since 3.11.0
830830
*
@@ -842,12 +842,12 @@ var DynamicTilemapLayer = new Class({
842842
},
843843

844844
/**
845-
* When a Camera culls the tiles in this layer it does so using its view into the world, building up a
845+
* When a Camera culls the tiles in this layer it does so using its view into the world, building up a
846846
* rectangle inside which the tiles must exist or they will be culled. Sometimes you may need to expand the size
847847
* of this 'cull rectangle', especially if you plan on rotating the Camera viewing the layer. Do so
848848
* by providing the padding values. The values given are in tiles, not pixels. So if the tile width was 32px
849849
* and you set `paddingX` to be 4, it would add 32px x 4 to the cull rectangle (adjusted for scale)
850-
*
850+
*
851851
* @method Phaser.Tilemaps.DynamicTilemapLayer#setCullPadding
852852
* @since 3.11.0
853853
*

src/tilemaps/staticlayer/StaticTilemapLayer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ var StaticTilemapLayer = new Class({
237237
var row;
238238
var col;
239239
var texCoords;
240-
240+
241241
var vertexBuffer = this.vertexBuffer;
242242
var bufferData = this.bufferData;
243243
var voffset = -1;
@@ -433,7 +433,7 @@ var StaticTilemapLayer = new Class({
433433
* @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted
434434
* tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a
435435
* one-to-one mapping with the indexes array.
436-
* @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e.
436+
* @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e.
437437
* scene.make.sprite).
438438
* @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within.
439439
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY

0 commit comments

Comments
 (0)