Skip to content

Commit 326cb75

Browse files
committed
Docs fixes.
1 parent 25178fd commit 326cb75

1 file changed

Lines changed: 60 additions & 47 deletions

File tree

src/gameobjects/GameObjectFactory.js

Lines changed: 60 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ Phaser.GameObjectFactory = function (game) {
3333
Phaser.GameObjectFactory.prototype = {
3434

3535
/**
36-
* Adds an existing object to the game world.
36+
* Adds an existing display object to the game world.
37+
*
3738
* @method Phaser.GameObjectFactory#existing
38-
* @param {any} object - An instance of Phaser.Sprite, Phaser.Button or any other display object..
39-
* @return {any} The child that was added to the Group.
39+
* @param {any} object - An instance of Phaser.Sprite, Phaser.Button or any other display object.
40+
* @return {any} The child that was added to the World.
4041
*/
4142
existing: function (object) {
4243

@@ -45,16 +46,20 @@ Phaser.GameObjectFactory.prototype = {
4546
},
4647

4748
/**
48-
* Create a new `Image` object. An Image is a light-weight object you can use to display anything that doesn't need physics or animation.
49-
* It can still rotate, scale, crop and receive input events. This makes it perfect for logos, backgrounds, simple buttons and other non-Sprite graphics.
49+
* Create a new `Image` object.
50+
*
51+
* An Image is a light-weight object you can use to display anything that doesn't need physics or animation.
52+
*
53+
* It can still rotate, scale, crop and receive input events.
54+
* This makes it perfect for logos, backgrounds, simple buttons and other non-Sprite graphics.
5055
*
5156
* @method Phaser.GameObjectFactory#image
52-
* @param {number} x - X position of the image.
53-
* @param {number} y - Y position of the image.
54-
* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
55-
* @param {string|number} [frame] - If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name.
57+
* @param {number} [x=0] - The x coordinate of the Image. The coordinate is relative to any parent container this Image may be in.
58+
* @param {number} [y=0] - The y coordinate of the Image. The coordinate is relative to any parent container this Image may be in.
59+
* @param {string|Phaser.RenderTexture|Phaser.BitmapData|Phaser.Video|PIXI.Texture} [key] - The image used as a texture by this display object during rendering. If a string Phaser will get for an entry in the Image Cache. Or it can be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture.
60+
* @param {string|number} [frame] - If a Texture Atlas or Sprite Sheet is used this allows you to specify the frame to be used. Use either an integer for a Frame ID or a string for a frame name.
5661
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
57-
* @returns {Phaser.Sprite} the newly created sprite object.
62+
* @returns {Phaser.Image} The newly created Image object.
5863
*/
5964
image: function (x, y, key, frame, group) {
6065

@@ -67,13 +72,17 @@ Phaser.GameObjectFactory.prototype = {
6772
/**
6873
* Create a new Sprite with specific position and sprite sheet key.
6974
*
75+
* At its most basic a Sprite consists of a set of coordinates and a texture that is used when rendered.
76+
* They also contain additional properties allowing for physics motion (via Sprite.body), input handling (via Sprite.input),
77+
* events (via Sprite.events), animation (via Sprite.animations), camera culling and more. Please see the Examples for use cases.
78+
*
7079
* @method Phaser.GameObjectFactory#sprite
71-
* @param {number} x - X position of the new sprite.
72-
* @param {number} y - Y position of the new sprite.
73-
* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
74-
* @param {string|number} [frame] - If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name.
80+
* @param {number} [x=0] - The x coordinate of the sprite. The coordinate is relative to any parent container this sprite may be in.
81+
* @param {number} [y=0] - The y coordinate of the sprite. The coordinate is relative to any parent container this sprite may be in.
82+
* @param {string|Phaser.RenderTexture|Phaser.BitmapData|Phaser.Video|PIXI.Texture} [key] - The image used as a texture by this display object during rendering. If a string Phaser will get for an entry in the Image Cache. Or it can be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture.
83+
* @param {string|number} [frame] - If a Texture Atlas or Sprite Sheet is used this allows you to specify the frame to be used. Use either an integer for a Frame ID or a string for a frame name.
7584
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
76-
* @returns {Phaser.Sprite} the newly created sprite object.
85+
* @returns {Phaser.Sprite} The newly created Sprite object.
7786
*/
7887
sprite: function (x, y, key, frame, group) {
7988

@@ -84,15 +93,17 @@ Phaser.GameObjectFactory.prototype = {
8493
},
8594

8695
/**
87-
* Create a tween on a specific object. The object can be any JavaScript object or Phaser object such as Sprite.
96+
* Create a tween on a specific object.
97+
*
98+
* The object can be any JavaScript object or Phaser object such as Sprite.
8899
*
89100
* @method Phaser.GameObjectFactory#tween
90-
* @param {object} obj - Object the tween will be run on.
101+
* @param {object} object - Object the tween will be run on.
91102
* @return {Phaser.Tween} The newly created Phaser.Tween object.
92103
*/
93-
tween: function (obj) {
104+
tween: function (object) {
94105

95-
return this.game.tweens.create(obj);
106+
return this.game.tweens.create(object);
96107

97108
},
98109

@@ -105,7 +116,7 @@ Phaser.GameObjectFactory.prototype = {
105116
* @param {boolean} [addToStage=false] - If set to true this Group will be added directly to the Game.Stage instead of Game.World.
106117
* @param {boolean} [enableBody=false] - If true all Sprites created with `Group.create` or `Group.createMulitple` will have a physics body created on them. Change the body type with physicsBodyType.
107118
* @param {number} [physicsBodyType=0] - If enableBody is true this is the type of physics body that is created on new Sprites. Phaser.Physics.ARCADE, Phaser.Physics.P2, Phaser.Physics.NINJA, etc.
108-
* @return {Phaser.Group} The newly created group.
119+
* @return {Phaser.Group} The newly created Group.
109120
*/
110121
group: function (parent, name, addToStage, enableBody, physicsBodyType) {
111122

@@ -115,6 +126,7 @@ Phaser.GameObjectFactory.prototype = {
115126

116127
/**
117128
* A Group is a container for display objects that allows for fast pooling, recycling and collision checks.
129+
*
118130
* A Physics Group is the same as an ordinary Group except that is has enableBody turned on by default, so any Sprites it creates
119131
* are automatically given a physics body.
120132
*
@@ -123,7 +135,7 @@ Phaser.GameObjectFactory.prototype = {
123135
* @param {any} [parent] - The parent Group or DisplayObjectContainer that will hold this group, if any. If set to null the Group won't be added to the display list. If undefined it will be added to World by default.
124136
* @param {string} [name='group'] - A name for this Group. Not used internally but useful for debugging.
125137
* @param {boolean} [addToStage=false] - If set to true this Group will be added directly to the Game.Stage instead of Game.World.
126-
* @return {Phaser.Group} The newly created group.
138+
* @return {Phaser.Group} The newly created Group.
127139
*/
128140
physicsGroup: function (physicsBodyType, parent, name, addToStage) {
129141

@@ -140,7 +152,7 @@ Phaser.GameObjectFactory.prototype = {
140152
* @param {Phaser.Group|null} parent - The parent Group that will hold this Sprite Batch. Set to `undefined` or `null` to add directly to game.world.
141153
* @param {string} [name='group'] - A name for this Sprite Batch. Not used internally but useful for debugging.
142154
* @param {boolean} [addToStage=false] - If set to true this Sprite Batch will be added directly to the Game.Stage instead of the parent.
143-
* @return {Phaser.Group} The newly created group.
155+
* @return {Phaser.SpriteBatch} The newly created Sprite Batch.
144156
*/
145157
spriteBatch: function (parent, name, addToStage) {
146158

@@ -160,7 +172,7 @@ Phaser.GameObjectFactory.prototype = {
160172
* @param {number} [volume=1] - The volume at which the sound will be played.
161173
* @param {boolean} [loop=false] - Whether or not the sound will loop.
162174
* @param {boolean} [connect=true] - Controls if the created Sound object will connect to the master gainNode of the SoundManager when running under WebAudio.
163-
* @return {Phaser.Sound} The newly created text object.
175+
* @return {Phaser.Sound} The newly created sound object.
164176
*/
165177
audio: function (key, volume, loop, connect) {
166178

@@ -176,7 +188,7 @@ Phaser.GameObjectFactory.prototype = {
176188
* @param {number} [volume=1] - The volume at which the sound will be played.
177189
* @param {boolean} [loop=false] - Whether or not the sound will loop.
178190
* @param {boolean} [connect=true] - Controls if the created Sound object will connect to the master gainNode of the SoundManager when running under WebAudio.
179-
* @return {Phaser.Sound} The newly created text object.
191+
* @return {Phaser.Sound} The newly created sound object.
180192
*/
181193
sound: function (key, volume, loop, connect) {
182194

@@ -201,14 +213,14 @@ Phaser.GameObjectFactory.prototype = {
201213
* Creates a new TileSprite object.
202214
*
203215
* @method Phaser.GameObjectFactory#tileSprite
204-
* @param {number} x - The x coordinate (in world space) to position the TileSprite at.
205-
* @param {number} y - The y coordinate (in world space) to position the TileSprite at.
216+
* @param {number} x - The x coordinate of the TileSprite. The coordinate is relative to any parent container this TileSprite may be in.
217+
* @param {number} y - The y coordinate of the TileSprite. The coordinate is relative to any parent container this TileSprite may be in.
206218
* @param {number} width - The width of the TileSprite.
207219
* @param {number} height - The height of the TileSprite.
208-
* @param {string|Phaser.RenderTexture|Phaser.BitmapData|PIXI.Texture} key - This is the image or texture used by the TileSprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
209-
* @param {string|number} frame - If this TileSprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.
220+
* @param {string|Phaser.RenderTexture|Phaser.BitmapData|Phaser.Video|PIXI.Texture} key - The image used as a texture by this display object during rendering. If a string Phaser will get for an entry in the Image Cache. Or it can be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture.
221+
* @param {string|number} [frame] - If a Texture Atlas or Sprite Sheet is used this allows you to specify the frame to be used. Use either an integer for a Frame ID or a string for a frame name.
210222
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
211-
* @return {Phaser.TileSprite} The newly created tileSprite object.
223+
* @return {Phaser.TileSprite} The newly created TileSprite object.
212224
*/
213225
tileSprite: function (x, y, width, height, key, frame, group) {
214226

@@ -221,15 +233,16 @@ Phaser.GameObjectFactory.prototype = {
221233
/**
222234
* Creates a new Rope object.
223235
*
236+
* Example usage: https://github.com/codevinsky/phaser-rope-demo/blob/master/dist/demo.js
237+
*
224238
* @method Phaser.GameObjectFactory#rope
225-
* @param {number} x - The x coordinate (in world space) to position the TileSprite at.
226-
* @param {number} y - The y coordinate (in world space) to position the TileSprite at.
227-
* @param {string|Phaser.RenderTexture|Phaser.BitmapData|PIXI.Texture} key - This is the image or texture used by the TileSprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
228-
* @param {string|number} frame - If this TileSprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.
239+
* @param {number} [x=0] - The x coordinate of the Rope. The coordinate is relative to any parent container this rope may be in.
240+
* @param {number} [y=0] - The y coordinate of the Rope. The coordinate is relative to any parent container this rope may be in.
241+
* @param {string|Phaser.RenderTexture|Phaser.BitmapData|Phaser.Video|PIXI.Texture} [key] - The image used as a texture by this display object during rendering. If a string Phaser will get for an entry in the Image Cache. Or it can be an instance of a RenderTexture, BitmapData, Video or PIXI.Texture.
242+
* @param {string|number} [frame] - If a Texture Atlas or Sprite Sheet is used this allows you to specify the frame to be used. Use either an integer for a Frame ID or a string for a frame name.
229243
* @param {Array} points - An array of {Phaser.Point}.
230244
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
231-
* @return {Phaser.TileSprite} The newly created tileSprite object.
232-
* Example usage: https://github.com/codevinsky/phaser-rope-demo/blob/master/dist/demo.js
245+
* @return {Phaser.Rope} The newly created Rope object.
233246
*/
234247
rope: function (x, y, key, frame, points, group) {
235248

@@ -243,10 +256,10 @@ Phaser.GameObjectFactory.prototype = {
243256
* Creates a new Text object.
244257
*
245258
* @method Phaser.GameObjectFactory#text
246-
* @param {number} x - X position of the new text object.
247-
* @param {number} y - Y position of the new text object.
248-
* @param {string} text - The actual text that will be written.
249-
* @param {object} style - The style object containing style attributes like font, font size , etc.
259+
* @param {number} [x=0] - The x coordinate of the Text. The coordinate is relative to any parent container this text may be in.
260+
* @param {number} [y=0] - The y coordinate of the Text. The coordinate is relative to any parent container this text may be in.
261+
* @param {string} [text=''] - The text string that will be displayed.
262+
* @param {object} [style] - The style object containing style attributes like font, font size , etc.
250263
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
251264
* @return {Phaser.Text} The newly created text object.
252265
*/
@@ -262,8 +275,8 @@ Phaser.GameObjectFactory.prototype = {
262275
* Creates a new Button object.
263276
*
264277
* @method Phaser.GameObjectFactory#button
265-
* @param {number} [x] - X position of the new button object.
266-
* @param {number} [y] - Y position of the new button object.
278+
* @param {number} [x=0] - The x coordinate of the Button. The coordinate is relative to any parent container this button may be in.
279+
* @param {number} [y=0] - The y coordinate of the Button. The coordinate is relative to any parent container this button may be in.
267280
* @param {string} [key] - The image key as defined in the Game.Cache to use as the texture for this button.
268281
* @param {function} [callback] - The function to call when this button is pressed
269282
* @param {object} [callbackContext] - The context in which the callback will be called (usually 'this')
@@ -272,7 +285,7 @@ Phaser.GameObjectFactory.prototype = {
272285
* @param {string|number} [downFrame] - This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name.
273286
* @param {string|number} [upFrame] - This is the frame or frameName that will be set when this button is in an up state. Give either a number to use a frame ID or a string for a frame name.
274287
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
275-
* @return {Phaser.Button} The newly created button object.
288+
* @return {Phaser.Button} The newly created Button object.
276289
*/
277290
button: function (x, y, key, callback, callbackContext, overFrame, outFrame, downFrame, upFrame, group) {
278291

@@ -286,8 +299,8 @@ Phaser.GameObjectFactory.prototype = {
286299
* Creates a new Graphics object.
287300
*
288301
* @method Phaser.GameObjectFactory#graphics
289-
* @param {number} x - X position of the new graphics object.
290-
* @param {number} y - Y position of the new graphics object.
302+
* @param {number} [x=0] - The x coordinate of the Graphic. The coordinate is relative to any parent container this object may be in.
303+
* @param {number} [y=0] - The y coordinate of the Graphic. The coordinate is relative to any parent container this object may be in.
291304
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
292305
* @return {Phaser.Graphics} The newly created graphics object.
293306
*/
@@ -310,7 +323,7 @@ Phaser.GameObjectFactory.prototype = {
310323
* @param {number} [x=0] - The x coordinate within the Emitter that the particles are emitted from.
311324
* @param {number} [y=0] - The y coordinate within the Emitter that the particles are emitted from.
312325
* @param {number} [maxParticles=50] - The total number of particles in this emitter.
313-
* @return {Phaser.Emitter} The newly created emitter object.
326+
* @return {Phaser.Particles.Arcade.Emitter} The newly created emitter object.
314327
*/
315328
emitter: function (x, y, maxParticles) {
316329

@@ -350,8 +363,8 @@ Phaser.GameObjectFactory.prototype = {
350363
* Create a new BitmapText object.
351364
*
352365
* @method Phaser.GameObjectFactory#bitmapText
353-
* @param {number} x - X position of the new bitmapText object.
354-
* @param {number} y - Y position of the new bitmapText object.
366+
* @param {number} x - The x coordinate of the BitmapText. The coordinate is relative to any parent container this object may be in.
367+
* @param {number} y - The y coordinate of the BitmapText. The coordinate is relative to any parent container this object may be in.
355368
* @param {string} font - The key of the BitmapText font as stored in Game.Cache.
356369
* @param {string} [text] - The actual text that will be rendered. Can be set later via BitmapText.text.
357370
* @param {number} [size] - The size the font will be rendered in, in pixels.

0 commit comments

Comments
 (0)