@@ -4,6 +4,33 @@ var GameObject = require('../../GameObject');
44var GetBitmapTextSize = require ( '../GetBitmapTextSize' ) ;
55var 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+ */
734var 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 ) ;
0 commit comments