Skip to content

Commit 50c787a

Browse files
committed
- add typedef for SpriteConfig extends GameObjectConfig
- allow update-function signature to be overriden by GameObject subclasses
1 parent 72dbfcd commit 50c787a

6 files changed

Lines changed: 39 additions & 29 deletions

File tree

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/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)