Skip to content

Commit 79de1b8

Browse files
committed
Added jsdocs
1 parent 4a63326 commit 79de1b8

2 files changed

Lines changed: 171 additions & 18 deletions

File tree

src/gameobjects/blitter/Blitter.js

Lines changed: 99 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@ var DisplayList = require('../DisplayList');
66
var Frame = require('../../textures/Frame');
77
var GameObject = require('../GameObject');
88

9-
/**
10-
* A Blitter Game Object.
11-
*
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.
16-
*/
17-
189
var Blitter = new Class({
1910

2011
Extends: GameObject,
@@ -33,22 +24,70 @@ var Blitter = new Class({
3324

3425
initialize:
3526

27+
/**
28+
* A Blitter Game Object.
29+
*
30+
* The Blitter Game Object is a special type of Container, that contains Blitter.Bob objects.
31+
* These objects can be thought of as just texture frames with a position and nothing more.
32+
* Bobs don't have any update methods, or the ability to have children, or any kind of special effects.
33+
* They are essentially just super-fast texture frame renderers, and the Blitter object creates and manages them.
34+
*
35+
* @class Blitter
36+
* @extends Phaser.GameObjects.GameObject
37+
* @memberOf Phaser.GameObjects
38+
* @constructor
39+
* @since 3.0.0
40+
*
41+
* @mixes Phaser.GameObjects.Components.Alpha
42+
*
43+
* @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time.
44+
* @param {number} [x==] - The x coordinate of this Game Object in world space.
45+
* @param {number} [y=0] - The y coordinate of this Game Object in world space.
46+
* @param {string} [texture='__DEFAULT'] - The key of the texture this Game Object will use for rendering. The Texture must already exist in the Texture Manager.
47+
* @param {string|integer} [frame=0] - The Frame of the Texture that this Game Object will use. Only set if the Texture has multiple frames, such as a Texture Atlas or Sprite Sheet.
48+
*/
3649
function Blitter (scene, x, y, texture, frame)
3750
{
3851
GameObject.call(this, scene, 'Blitter');
3952

4053
this.setTexture(texture, frame);
54+
4155
this.setPosition(x, y);
4256

57+
/**
58+
* [description]
59+
*
60+
* @property {Phaser.GameObjects.DisplayList} children
61+
* @since 3.0.0
62+
*/
4363
this.children = new DisplayList();
4464

65+
/**
66+
* [description]
67+
*
68+
* @property {array} renderList
69+
* @default []
70+
* @since 3.0.0
71+
*/
4572
this.renderList = [];
4673

4774
this.dirty = false;
4875
},
4976

50-
// frame MUST be part of the Blitter texture
51-
// and can be either a Frame object or a string
77+
/**
78+
* [description]
79+
*
80+
* @method Phaser.GameObjects.Blitter#create
81+
* @since 3.0.0
82+
*
83+
* @param {number} x - The x position of the Bob. Bob coordinate are relative to the position of the Blitter object.
84+
* @param {number} y - The y position of the Bob. Bob coordinate are relative to the position of the Blitter object.
85+
* @param {string|integer|Phaser.Textures.Frame} [frame] - The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using.
86+
* @param {boolean} [visible=true] - Should the created Bob render or not?
87+
* @param {integer} [index] - The position in the Blitters Display List to add the new Bob at. Defaults to the top of the list.
88+
*
89+
* @return {Phaser.GameObjects.Blitter.Bob} The newly created Bob object.
90+
*/
5291
create: function (x, y, frame, visible, index)
5392
{
5493
if (visible === undefined) { visible = true; }
@@ -73,6 +112,19 @@ var Blitter = new Class({
73112
},
74113

75114
// frame MUST be part of the Blitter texture
115+
/**
116+
* [description]
117+
*
118+
* @method Phaser.GameObjects.Blitter#createFromCallback
119+
* @since 3.0.0
120+
*
121+
* @param {[type]} callback - [description]
122+
* @param {[type]} quantity - [description]
123+
* @param {[type]} frame - [description]
124+
* @param {[type]} visible - [description]
125+
*
126+
* @return {[type]} [description]
127+
*/
76128
createFromCallback: function (callback, quantity, frame, visible)
77129
{
78130
var bobs = this.createMultiple(quantity, frame, visible);
@@ -88,6 +140,18 @@ var Blitter = new Class({
88140
},
89141

90142
// frame MUST be part of the Blitter texture
143+
/**
144+
* [description]
145+
*
146+
* @method Phaser.GameObjects.Blitter#createMultiple
147+
* @since 3.0.0
148+
*
149+
* @param {[type]} quantity - [description]
150+
* @param {[type]} frame - [description]
151+
* @param {[type]} visible - [description]
152+
*
153+
* @return {[type]} [description]
154+
*/
91155
createMultiple: function (quantity, frame, visible)
92156
{
93157
if (frame === undefined) { frame = this.frame.name; }
@@ -112,11 +176,29 @@ var Blitter = new Class({
112176
return bobs;
113177
},
114178

179+
/**
180+
* [description]
181+
*
182+
* @method Phaser.GameObjects.Blitter#childCanRender
183+
* @since 3.0.0
184+
*
185+
* @param {[type]} child - [description]
186+
*
187+
* @return {[type]} [description]
188+
*/
115189
childCanRender: function (child)
116190
{
117191
return (child.visible && child.alpha > 0);
118192
},
119193

194+
/**
195+
* [description]
196+
*
197+
* @method Phaser.GameObjects.Blitter#getRenderList
198+
* @since 3.0.0
199+
*
200+
* @return {[type]} [description]
201+
*/
120202
getRenderList: function ()
121203
{
122204
if (this.dirty)
@@ -128,6 +210,12 @@ var Blitter = new Class({
128210
return this.renderList;
129211
},
130212

213+
/**
214+
* [description]
215+
*
216+
* @method Phaser.GameObjects.Blitter#clear
217+
* @since 3.0.0
218+
*/
131219
clear: function ()
132220
{
133221
this.children.removeAll();

src/gameobjects/components/Alpha.js

Lines changed: 72 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
var Clamp = require('../../math/Clamp');
22

3-
// Alpha Component
3+
/**
4+
* Provides methods used for setting the alpha properties of a Game Object.
5+
* Should be applied as a mixin and not used directly.
6+
*
7+
* @name Phaser.GameObjects.Components.Alpha
8+
* @mixin
9+
* @since 3.0.0
10+
*/
411

512
// bitmask flag for GameObject.renderMask
613
var _FLAG = 2; // 0010
@@ -14,11 +21,32 @@ var Alpha = {
1421
_alphaBL: 1,
1522
_alphaBR: 1,
1623

24+
/**
25+
* [description]
26+
*
27+
* @method Phaser.GameObjects.Components.Alpha.clearAlpha
28+
* @since 3.0.0
29+
*
30+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
31+
*/
1732
clearAlpha: function ()
1833
{
1934
return this.setAlpha(1);
2035
},
2136

37+
/**
38+
* [description]
39+
*
40+
* @method Phaser.GameObjects.Components.Alpha.setAlpha
41+
* @since 3.0.0
42+
*
43+
* @param {float} [topLeft=1] - The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object.
44+
* @param {float} [topRight] - The alpha value used for the top-right of the Game Object.
45+
* @param {float} [bottomLeft] - The alpha value used for the bottom-left of the Game Object.
46+
* @param {float} [bottomRight] - The alpha value used for the bottom-right of the Game Object.
47+
*
48+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
49+
*/
2250
setAlpha: function (topLeft, topRight, bottomLeft, bottomRight)
2351
{
2452
if (topLeft === undefined) { topLeft = 1; }
@@ -39,7 +67,13 @@ var Alpha = {
3967
return this;
4068
},
4169

42-
// Global Alpha value. If changed this adjusts all alpha properties (topLeft, topRight, etc)
70+
/**
71+
* [description]
72+
*
73+
* @name Phaser.GameObjects.Components.Alpha#alpha
74+
* @property {float} alpha
75+
* @since 3.0.0
76+
*/
4377
alpha: {
4478

4579
get: function ()
@@ -69,7 +103,14 @@ var Alpha = {
69103

70104
},
71105

72-
// Adjusts the alpha value of the top-left vertex (WebGL only)
106+
/**
107+
* [description]
108+
*
109+
* @name Phaser.GameObjects.Components.Alpha#alphaTopLeft
110+
* @property {float} alphaTopLeft
111+
* @webglOnly
112+
* @since 3.0.0
113+
*/
73114
alphaTopLeft: {
74115

75116
get: function ()
@@ -81,7 +122,7 @@ var Alpha = {
81122
{
82123
var v = Clamp(value, 0, 1);
83124

84-
this._alphaTL = v
125+
this._alphaTL = v;
85126

86127
if (v !== 0)
87128
{
@@ -91,6 +132,14 @@ var Alpha = {
91132

92133
},
93134

135+
/**
136+
* [description]
137+
*
138+
* @name Phaser.GameObjects.Components.Alpha#alphaTopRight
139+
* @property {float} alphaTopRight
140+
* @webglOnly
141+
* @since 3.0.0
142+
*/
94143
alphaTopRight: {
95144

96145
get: function ()
@@ -102,7 +151,7 @@ var Alpha = {
102151
{
103152
var v = Clamp(value, 0, 1);
104153

105-
this._alphaTR = v
154+
this._alphaTR = v;
106155

107156
if (v !== 0)
108157
{
@@ -112,6 +161,14 @@ var Alpha = {
112161

113162
},
114163

164+
/**
165+
* [description]
166+
*
167+
* @name Phaser.GameObjects.Components.Alpha#alphaBottomLeft
168+
* @property {float} alphaBottomLeft
169+
* @webglOnly
170+
* @since 3.0.0
171+
*/
115172
alphaBottomLeft: {
116173

117174
get: function ()
@@ -123,7 +180,7 @@ var Alpha = {
123180
{
124181
var v = Clamp(value, 0, 1);
125182

126-
this._alphaBL = v
183+
this._alphaBL = v;
127184

128185
if (v !== 0)
129186
{
@@ -133,6 +190,14 @@ var Alpha = {
133190

134191
},
135192

193+
/**
194+
* [description]
195+
*
196+
* @name Phaser.GameObjects.Components.Alpha#alphaBottomRight
197+
* @property {float} alphaBottomRight
198+
* @webglOnly
199+
* @since 3.0.0
200+
*/
136201
alphaBottomRight: {
137202

138203
get: function ()
@@ -144,7 +209,7 @@ var Alpha = {
144209
{
145210
var v = Clamp(value, 0, 1);
146211

147-
this._alphaBR = v
212+
this._alphaBR = v;
148213

149214
if (v !== 0)
150215
{

0 commit comments

Comments
 (0)