Skip to content

Commit a8eae2b

Browse files
committed
Added jsdocs
1 parent 6df5137 commit a8eae2b

11 files changed

Lines changed: 454 additions & 25 deletions

src/gameobjects/bitmaptext/dynamic/DynamicBitmapText.js

Lines changed: 204 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,33 @@ var GameObject = require('../../GameObject');
44
var GetBitmapTextSize = require('../GetBitmapTextSize');
55
var Render = require('./DynamicBitmapTextRender');
66

7+
/**
8+
* [description]
9+
*
10+
* @class DynamicBitmapText
11+
* @extends Phaser.GameObjects.GameObject
12+
* @memberOf Phaser.GameObjects
13+
* @constructor
14+
* @since 3.0.0
15+
*
16+
* @extends Phaser.GameObjects.Components.Alpha
17+
* @extends Phaser.GameObjects.Components.BlendMode
18+
* @extends Phaser.GameObjects.Components.Depth
19+
* @extends Phaser.GameObjects.Components.Origin
20+
* @extends Phaser.GameObjects.Components.Pipeline
21+
* @extends Phaser.GameObjects.Components.Texture
22+
* @extends Phaser.GameObjects.Components.Tint
23+
* @extends Phaser.GameObjects.Components.Transform
24+
* @extends Phaser.GameObjects.Components.Visible
25+
* @extends Phaser.GameObjects.Components.ScrollFactor
26+
*
27+
* @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time.
28+
* @param {number} [x=0] - The x coordinate of this Game Object in world space.
29+
* @param {number} [y=0] - The y coordinate of this Game Object in world space.
30+
* @param {string} font - [description]
31+
* @param {string|string[]} [text] - [description]
32+
* @param {number} [size] - [description]
33+
*/
734
var DynamicBitmapText = new Class({
835

936
Extends: GameObject,
@@ -30,32 +57,120 @@ var DynamicBitmapText = new Class({
3057

3158
GameObject.call(this, scene, 'DynamicBitmapText');
3259

60+
/**
61+
* [description]
62+
*
63+
* @name Phaser.GameObjects.DynamicBitmapText#font
64+
* @type {string}
65+
* @since 3.0.0
66+
*/
3367
this.font = font;
3468

3569
var entry = this.scene.sys.cache.bitmapFont.get(font);
3670

71+
/**
72+
* [description]
73+
*
74+
* @name Phaser.GameObjects.DynamicBitmapText#fontData
75+
* @type {object}
76+
* @since 3.0.0
77+
*/
3778
this.fontData = entry.data;
3879

80+
/**
81+
* [description]
82+
*
83+
* @name Phaser.GameObjects.DynamicBitmapText#text
84+
* @type {string}
85+
* @since 3.0.0
86+
*/
3987
this.text = (Array.isArray(text)) ? text.join('\n') : text;
4088

89+
/**
90+
* [description]
91+
*
92+
* @name Phaser.GameObjects.DynamicBitmapText#fontSize
93+
* @type {number}
94+
* @since 3.0.0
95+
*/
4196
this.fontSize = size || this.fontData.size;
4297

4398
this.setTexture(entry.texture, entry.frame);
4499
this.setPosition(x, y);
45100
this.setOrigin(0, 0);
46101
this.initPipeline('TextureTintPipeline');
47102

103+
/**
104+
* [description]
105+
*
106+
* @name Phaser.GameObjects.DynamicBitmapText#_bounds
107+
* @type {object}
108+
* @private
109+
* @since 3.0.0
110+
*/
48111
this._bounds = this.getTextBounds();
49112

113+
/**
114+
* [description]
115+
*
116+
* @name Phaser.GameObjects.DynamicBitmapText#scrollX
117+
* @type {number}
118+
* @default 0
119+
* @since 3.0.0
120+
*/
50121
this.scrollX = 0;
122+
123+
/**
124+
* [description]
125+
*
126+
* @name Phaser.GameObjects.DynamicBitmapText#scrollY
127+
* @type {number}
128+
* @default 0
129+
* @since 3.0.0
130+
*/
51131
this.scrollY = 0;
52132

133+
/**
134+
* [description]
135+
*
136+
* @name Phaser.GameObjects.DynamicBitmapText#cropWidth
137+
* @type {number}
138+
* @default 0
139+
* @since 3.0.0
140+
*/
53141
this.cropWidth = 0;
142+
143+
/**
144+
* [description]
145+
*
146+
* @name Phaser.GameObjects.DynamicBitmapText#cropHeight
147+
* @type {number}
148+
* @default 0
149+
* @since 3.0.0
150+
*/
54151
this.cropHeight = 0;
55152

153+
/**
154+
* [description]
155+
*
156+
* @name Phaser.GameObjects.DynamicBitmapText#displayCallback;
157+
* @type {function}
158+
* @since 3.0.0
159+
*/
56160
this.displayCallback;
57161
},
58162

163+
/**
164+
* [description]
165+
*
166+
* @method Phaser.GameObjects.DynamicBitmapText#setSize
167+
* @since 3.0.0
168+
*
169+
* @param {number} width - [description]
170+
* @param {number} height - [description]
171+
*
172+
* @return {Phaser.GameObjects.DynamicBitmapText} This Game Object.
173+
*/
59174
setSize: function (width, height)
60175
{
61176
this.cropWidth = width;
@@ -64,34 +179,89 @@ var DynamicBitmapText = new Class({
64179
return this;
65180
},
66181

182+
/**
183+
* [description]
184+
*
185+
* @method Phaser.GameObjects.DynamicBitmapText#setDisplayCallback
186+
* @since 3.0.0
187+
*
188+
* @param {function} callback - [description]
189+
*
190+
* @return {Phaser.GameObjects.DynamicBitmapText} This Game Object.
191+
*/
67192
setDisplayCallback: function (callback)
68193
{
69194
this.displayCallback = callback;
70195

71196
return this;
72197
},
73198

199+
/**
200+
* [description]
201+
*
202+
* @method Phaser.GameObjects.DynamicBitmapText#setFontSize
203+
* @since 3.0.0
204+
*
205+
* @param {number} size - [description]
206+
*
207+
* @return {Phaser.GameObjects.DynamicBitmapText} This Game Object.
208+
*/
74209
setFontSize: function (size)
75210
{
76211
this.fontSize = size;
77212

78213
return this;
79214
},
80215

81-
setText: function (text)
216+
/**
217+
* [description]
218+
*
219+
* @method Phaser.GameObjects.DynamicBitmapText#setText
220+
* @since 3.0.0
221+
*
222+
* @param {string|string[]} text - [description]
223+
*
224+
* @return {Phaser.GameObjects.DynamicBitmapText} This Game Object.
225+
*/
226+
setText: function (value)
82227
{
83-
this.text = text;
228+
if (Array.isArray(value))
229+
{
230+
value = value.join('\n');
231+
}
232+
233+
this.text = value;
84234

85235
return this;
86236
},
87237

238+
/**
239+
* [description]
240+
*
241+
* @method Phaser.GameObjects.DynamicBitmapText#setScrollX
242+
* @since 3.0.0
243+
*
244+
* @param {number} value - [description]
245+
*
246+
* @return {Phaser.GameObjects.DynamicBitmapText} This Game Object.
247+
*/
88248
setScrollX: function (value)
89249
{
90250
this.scrollX = value;
91251

92252
return this;
93253
},
94254

255+
/**
256+
* [description]
257+
*
258+
* @method Phaser.GameObjects.DynamicBitmapText#setScrollY
259+
* @since 3.0.0
260+
*
261+
* @param {number} value - [description]
262+
*
263+
* @return {Phaser.GameObjects.DynamicBitmapText} This Game Object.
264+
*/
95265
setScrollY: function (value)
96266
{
97267
this.scrollY = value;
@@ -114,6 +284,16 @@ var DynamicBitmapText = new Class({
114284
// }
115285
// }
116286

287+
/**
288+
* [description]
289+
*
290+
* @method Phaser.GameObjects.DynamicBitmapText#getTextBounds
291+
* @since 3.0.0
292+
*
293+
* @param {boolean} round - [description]
294+
*
295+
* @return {object} [description]
296+
*/
117297
getTextBounds: function (round)
118298
{
119299
// local = the BitmapText based on fontSize and 0x0 coords
@@ -124,6 +304,13 @@ var DynamicBitmapText = new Class({
124304
return this._bounds;
125305
},
126306

307+
/**
308+
* [description]
309+
*
310+
* @name Phaser.GameObjects.DynamicBitmapText#width
311+
* @type {number}
312+
* @since 3.0.0
313+
*/
127314
width: {
128315

129316
get: function ()
@@ -134,6 +321,13 @@ var DynamicBitmapText = new Class({
134321

135322
},
136323

324+
/**
325+
* [description]
326+
*
327+
* @name Phaser.GameObjects.DynamicBitmapText#height
328+
* @type {number}
329+
* @since 3.0.0
330+
*/
137331
height: {
138332

139333
get: function ()
@@ -144,6 +338,14 @@ var DynamicBitmapText = new Class({
144338

145339
},
146340

341+
/**
342+
* [description]
343+
*
344+
* @method Phaser.GameObjects.DynamicBitmapText#toJSON
345+
* @since 3.0.0
346+
*
347+
* @return {object} [description]
348+
*/
147349
toJSON: function ()
148350
{
149351
var out = Components.ToJSON(this);

src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.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.DynamicBitmapText#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.DynamicBitmapText} 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 DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera)
418
{
519
var text = src.text;

src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCreator.js

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

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

1929
return bitmapText;
2030
});
31+
32+
// When registering a factory function 'this' refers to the GameObjectCreator context.

src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextFactory.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
11
var DynamicBitmapText = require('./DynamicBitmapText');
22
var GameObjectFactory = require('../../GameObjectFactory');
33

4+
/**
5+
* Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene.
6+
*
7+
* Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser.
8+
*
9+
* @method Phaser.GameObjects.GameObjectFactory#dynamicBitmapText
10+
* @since 3.0.0
11+
*
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} font - [description]
15+
* @param {string|string[]} [text] - [description]
16+
* @param {number} [size] - [description]
17+
*
18+
* @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created.
19+
*/
20+
GameObjectFactory.register('dynamicBitmapText', function (x, y, font, text, size)
21+
{
22+
return this.displayList.add(new DynamicBitmapText(this.scene, x, y, font, text, size));
23+
});
24+
425
// When registering a factory function 'this' refers to the GameObjectFactory context.
526
//
627
// There are several properties available to use:
728
//
829
// this.scene - a reference to the Scene that owns the GameObjectFactory
930
// this.displayList - a reference to the Display List the Scene owns
1031
// this.updateList - a reference to the Update List the Scene owns
11-
12-
GameObjectFactory.register('dynamicBitmapText', function (x, y, font, text, size)
13-
{
14-
return this.displayList.add(new DynamicBitmapText(this.scene, x, y, font, text, size));
15-
});

0 commit comments

Comments
 (0)