Skip to content

Commit a4381d6

Browse files
committed
Added jsdocs
1 parent d922742 commit a4381d6

9 files changed

Lines changed: 185 additions & 31 deletions

File tree

src/gameobjects/blitter/Blitter.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@ var GameObject = require('../GameObject');
99
/**
1010
* A Blitter Game Object.
1111
*
12-
* The Blitter Game Object is a special type of Container, that contains Blitter.Bob objects.
13-
* These objects can be thought of as just texture frames with a position and nothing more.
14-
* Bobs don't have any update methods, or the ability to have children, or any kind of special effects.
15-
* They are essentially just super-fast texture frame renderers, and the Blitter object creates and manages them.
12+
* The Blitter Game Object is a special kind of container that creates, updates and manages Bob objects.
13+
* Bobs are designed for rendering speed rather than flexibility. They consist of a texture, or frame from a texture,
14+
* a position and an alpha value. You cannot scale or rotate them. They use a batched drawing method for speed
15+
* during rendering.
16+
*
17+
* A Blitter Game Object has one texture bound to it. Bobs created by the Blitter can use any Frame from this
18+
* Texture to render with, but they cannot use any other Texture. It is this single texture-bind that allows
19+
* them their speed.
20+
*
21+
* If you have a need to blast a large volume of frames around the screen then Blitter objects are well worth
22+
* investigating. They are especially useful for using as a base for your own special effects systems.
1623
*
1724
* @class Blitter
1825
* @extends Phaser.GameObjects.GameObject

src/gameobjects/blitter/Bob.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
var Class = require('../../utils/Class');
22

33
/**
4-
* [description]
4+
* A Bob Game Object.
5+
*
6+
* A Bob belongs to a Blitter Game Object. The Blitter is responsible for managing and rendering this object.
7+
*
8+
* A Bob has a position, alpha value and a frame from a texture that it uses to render with. You can also toggle
9+
* the flipped and visible state of the Bob. The Frame the Bob uses to render can be changed dynamically, but it
10+
* must be a Frame within the Texture used by the parent Blitter.
11+
*
12+
* Bob positions are relative to the Blitter parent. So if you move the Blitter parent, all Bob children will
13+
* have their positions impacted by this change as well.
14+
*
15+
* You can manipulate Bob objects directly from your game code, but the creation and destruction of them should be
16+
* handled via the Blitter parent.
517
*
618
* @class Bob
719
* @memberOf Phaser.GameObjects.Blitter
820
* @constructor
921
* @since 3.0.0
1022
*
11-
* @param {Phaser.GameObjects.Blitter} blitter - [description]
12-
* @param {number} x - [description]
13-
* @param {number} y - [description]
14-
* @param {string|integer} frame - [description]
15-
* @param {boolean} visible - [description]
23+
* @param {Phaser.GameObjects.Blitter} blitter - The parent Blitter object is responsible for updating this Bob.
24+
* @param {number} x - The horizontal position of this Game Object in the world, relative to the parent Blitter position.
25+
* @param {number} y - The vertical position of this Game Object in the world, relative to the parent Blitter position.
26+
* @param {string|integer} frame - The Frame this Bob will render with, as defined in the Texture the parent Blitter is using.
27+
* @param {boolean} visible - Should the Bob render visible or not to start with?
1628
*/
1729
var Bob = new Class({
1830

src/gameobjects/image/Image.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ var GameObject = require('../GameObject');
44
var ImageRender = require('./ImageRender');
55

66
/**
7-
* [description]
7+
* An Image Game Object.
8+
*
9+
* An Image is a light-weight Game Object useful for the display of static images in your game,
10+
* such as logos, backgrounds, scenery or other non-animated elements. Images can have input
11+
* events and physics bodies, or be tweened, tinted or scrolled. The main difference between an
12+
* Image and a Sprite is that you cannot animate an Image as they do not have the Animation component.
813
*
914
* @class Image
1015
* @extends Phaser.GameObjects.GameObject
@@ -27,11 +32,11 @@ var ImageRender = require('./ImageRender');
2732
* @extends Phaser.GameObjects.Components.Transform
2833
* @extends Phaser.GameObjects.Components.Visible
2934
*
30-
* @param {Phaser.Scene} scene - [description]
31-
* @param {number} x - [description]
32-
* @param {number} y - [description]
33-
* @param {string} texture - [description]
34-
* @param {string|integer} frame - [description]
35+
* @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time.
36+
* @param {number} x - The horizontal position of this Game Object in the world.
37+
* @param {number} y - The vertical position of this Game Object in the world.
38+
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
39+
* @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with.
3540
*/
3641
var Image = new Class({
3742

src/gameobjects/image/ImageFactory.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ var GameObjectFactory = require('../GameObjectFactory');
99
* @method Phaser.GameObjects.GameObjectFactory#image
1010
* @since 3.0.0
1111
*
12-
* @param {number} x - The x position of the Game Object.
13-
* @param {number} y - The y position of the Game Object.
14-
* @param {string} key - The key of the Texture the Game Object will use.
15-
* @param {string|integer} [frame] - The Texture Frame the Game Object will use.
12+
* @param {number} x - The horizontal position of this Game Object in the world.
13+
* @param {number} y - The vertical position of this Game Object in the world.
14+
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
15+
* @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with.
1616
*
1717
* @return {Phaser.GameObjects.Image} The Game Object that was created.
1818
*/

src/gameobjects/sprite/Sprite.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,45 @@ var Components = require('../components');
33
var GameObject = require('../GameObject');
44
var SpriteRender = require('./SpriteRender');
55

6+
/**
7+
* A Sprite Game Object.
8+
*
9+
* A Sprite Game Object is used for the display of both static and animated images in your game.
10+
* Sprites can have inpt events and physics bodies. They can also be tweened, tinted, scrolled
11+
* and animated.
12+
*
13+
* The main difference between a Sprite and an Image Game Object is that you cannot animate Images.
14+
* As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation
15+
* Component. If you do not require animation then you can safely use Images to replace Sprites in all cases.
16+
*
17+
* @class Sprite
18+
* @extends Phaser.GameObjects.GameObject
19+
* @memberOf Phaser.GameObjects
20+
* @constructor
21+
* @since 3.0.0
22+
*
23+
* @extends Phaser.GameObjects.Components.Alpha
24+
* @extends Phaser.GameObjects.Components.Animation
25+
* @extends Phaser.GameObjects.Components.BlendMode
26+
* @extends Phaser.GameObjects.Components.Depth
27+
* @extends Phaser.GameObjects.Components.Flip
28+
* @extends Phaser.GameObjects.Components.GetBounds
29+
* @extends Phaser.GameObjects.Components.Origin
30+
* @extends Phaser.GameObjects.Components.Pipeline
31+
* @extends Phaser.GameObjects.Components.ScaleMode
32+
* @extends Phaser.GameObjects.Components.ScrollFactor
33+
* @extends Phaser.GameObjects.Components.Size
34+
* @extends Phaser.GameObjects.Components.Texture
35+
* @extends Phaser.GameObjects.Components.Tint
36+
* @extends Phaser.GameObjects.Components.Transform
37+
* @extends Phaser.GameObjects.Components.Visible
38+
*
39+
* @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time.
40+
* @param {number} x - The horizontal position of this Game Object in the world.
41+
* @param {number} y - The vertical position of this Game Object in the world.
42+
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
43+
* @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with.
44+
*/
645
var Sprite = new Class({
746

847
Extends: GameObject,
@@ -31,6 +70,13 @@ var Sprite = new Class({
3170
{
3271
GameObject.call(this, scene, 'Sprite');
3372

73+
/**
74+
* [description]
75+
*
76+
* @name Phaser.GameObjects.Sprite#anims
77+
* @type {[type]}
78+
* @since 3.0.0
79+
*/
3480
this.anims = new Components.Animation(this);
3581

3682
this.setTexture(texture, frame);
@@ -40,18 +86,47 @@ var Sprite = new Class({
4086
this.initPipeline('TextureTintPipeline');
4187
},
4288

89+
/**
90+
* [description]
91+
*
92+
* @method Phaser.GameObjects.Sprite#preUpdate
93+
* @since 3.0.0
94+
*
95+
* @param {number} time - [description]
96+
* @param {number} delta - [description]
97+
*/
4398
preUpdate: function (time, delta)
4499
{
45100
this.anims.update(time, delta);
46101
},
47102

103+
/**
104+
* [description]
105+
*
106+
* @method Phaser.GameObjects.Sprite#play
107+
* @since 3.0.0
108+
*
109+
* @param {string} key - [description]
110+
* @param {boolean} ignoreIfPlaying - [description]
111+
* @param {integer|string} startFrame - [description]
112+
*
113+
* @return {[type]} [description]
114+
*/
48115
play: function (key, ignoreIfPlaying, startFrame)
49116
{
50117
this.anims.play(key, ignoreIfPlaying, startFrame);
51118

52119
return this;
53120
},
54121

122+
/**
123+
* [description]
124+
*
125+
* @method Phaser.GameObjects.Sprite#toJSON
126+
* @since 3.0.0
127+
*
128+
* @return {object} [description]
129+
*/
55130
toJSON: function ()
56131
{
57132
var data = Components.ToJSON(this);

src/gameobjects/sprite/SpriteCanvasRenderer.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
var GameObject = require('../GameObject');
22

3+
/**
4+
* Renders this Game Object with the Canvas Renderer to the given Camera.
5+
* The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera.
6+
* This method should not be called directly. It is a utility function of the Render module.
7+
*
8+
* @method Phaser.GameObjects.Sprite#renderCanvas
9+
* @since 3.0.0
10+
* @private
11+
*
12+
* @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer.
13+
* @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call.
14+
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
15+
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
16+
*/
317
var SpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera)
418
{
519
if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)))

src/gameobjects/sprite/SpriteCreator.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@ var GameObjectCreator = require('../GameObjectCreator');
44
var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
55
var Sprite = require('./Sprite');
66

7-
// When registering a factory function 'this' refers to the GameObjectCreator context.
8-
7+
/**
8+
* Creates a new Sprite Game Object and returns it.
9+
*
10+
* Note: This method will only be available if the Sprite Game Object has been built into Phaser.
11+
*
12+
* @method Phaser.GameObjects.GameObjectCreator#sprite
13+
* @since 3.0.0
14+
*
15+
* @param {object} config - [description]
16+
*
17+
* @return {Phaser.GameObjects.Sprite} The Game Object that was created.
18+
*/
919
GameObjectCreator.register('sprite', function (config)
1020
{
1121
var key = GetAdvancedValue(config, 'key', null);
@@ -23,3 +33,5 @@ GameObjectCreator.register('sprite', function (config)
2333

2434
return sprite;
2535
});
36+
37+
// When registering a factory function 'this' refers to the GameObjectCreator context.
Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
var Sprite = require('./Sprite');
21
var GameObjectFactory = require('../GameObjectFactory');
2+
var Sprite = require('./Sprite');
33

4-
// When registering a factory function 'this' refers to the GameObjectFactory context.
5-
//
6-
// There are several properties available to use:
7-
//
8-
// this.scene - a reference to the Scene that owns the GameObjectFactory
9-
// this.displayList - a reference to the Display List the Scene owns
10-
// this.updateList - a reference to the Update List the Scene owns
11-
4+
/**
5+
* Creates a new Sprite Game Object and adds it to the Scene.
6+
*
7+
* Note: This method will only be available if the Sprite Game Object has been built into Phaser.
8+
*
9+
* @method Phaser.GameObjects.GameObjectFactory#sprite
10+
* @since 3.0.0
11+
*
12+
* @param {number} x - The horizontal position of this Game Object in the world.
13+
* @param {number} y - The vertical position of this Game Object in the world.
14+
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
15+
* @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with.
16+
*
17+
* @return {Phaser.GameObjects.Sprite} The Game Object that was created.
18+
*/
1219
GameObjectFactory.register('sprite', function (x, y, key, frame)
1320
{
1421
var sprite = new Sprite(this.scene, x, y, key, frame);
@@ -18,3 +25,11 @@ GameObjectFactory.register('sprite', function (x, y, key, frame)
1825

1926
return sprite;
2027
});
28+
29+
// When registering a factory function 'this' refers to the GameObjectFactory context.
30+
//
31+
// There are several properties available to use:
32+
//
33+
// this.scene - a reference to the Scene that owns the GameObjectFactory
34+
// this.displayList - a reference to the Display List the Scene owns
35+
// this.updateList - a reference to the Update List the Scene owns

src/gameobjects/sprite/SpriteWebGLRenderer.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
var GameObject = require('../GameObject');
22

3+
/**
4+
* Renders this Game Object with the WebGL Renderer to the given Camera.
5+
* The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera.
6+
* This method should not be called directly. It is a utility function of the Render module.
7+
*
8+
* @method Phaser.GameObjects.Sprite#renderWebGL
9+
* @since 3.0.0
10+
* @private
11+
*
12+
* @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer.
13+
* @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call.
14+
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
15+
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
16+
*/
317
var SpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera)
418
{
519
if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)))

0 commit comments

Comments
 (0)