Skip to content

Commit fcaa2bf

Browse files
committed
Completing Game Object jsdocs
1 parent 24e09d7 commit fcaa2bf

10 files changed

Lines changed: 193 additions & 3 deletions

File tree

src/gameobjects/bitmaptext/dynamic/DynamicBitmapText.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,31 @@ var Render = require('./DynamicBitmapTextRender');
3131

3232
/**
3333
* @classdesc
34-
* [description]
34+
* BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure.
35+
*
36+
* During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to
37+
* match the font structure.
38+
*
39+
* Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each
40+
* letter being rendered during the render pass. This callback allows you to manipulate the properties of
41+
* each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects
42+
* like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing
43+
* time, so only use them if you require the callback ability they have.
44+
*
45+
* BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability
46+
* to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by
47+
* processing the font texture in an image editor, applying fills and any other effects required.
48+
*
49+
* To create multi-line text insert \r, \n or \r\n escape codes into the text string.
50+
*
51+
* To create a BitmapText data files you need a 3rd party app such as:
52+
*
53+
* BMFont (Windows, free): http://www.angelcode.com/products/bmfont/
54+
* Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner
55+
* Littera (Web-based, free): http://kvazars.com/littera/
56+
*
57+
* For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of
58+
* converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson
3559
*
3660
* @class DynamicBitmapText
3761
* @extends Phaser.GameObjects.BitmapText

src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextFactory.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,32 @@ var GameObjectFactory = require('../../GameObjectFactory');
99

1010
/**
1111
* Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene.
12+
*
13+
* BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure.
14+
*
15+
* During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to
16+
* match the font structure.
17+
*
18+
* Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each
19+
* letter being rendered during the render pass. This callback allows you to manipulate the properties of
20+
* each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects
21+
* like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing
22+
* time, so only use them if you require the callback ability they have.
23+
*
24+
* BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability
25+
* to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by
26+
* processing the font texture in an image editor, applying fills and any other effects required.
27+
*
28+
* To create multi-line text insert \r, \n or \r\n escape codes into the text string.
29+
*
30+
* To create a BitmapText data files you need a 3rd party app such as:
31+
*
32+
* BMFont (Windows, free): http://www.angelcode.com/products/bmfont/
33+
* Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner
34+
* Littera (Web-based, free): http://kvazars.com/littera/
35+
*
36+
* For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of
37+
* converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson
1238
*
1339
* Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser.
1440
*

src/gameobjects/bitmaptext/static/BitmapText.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,25 @@ var Render = require('./BitmapTextRender');
5555

5656
/**
5757
* @classdesc
58-
* [description]
58+
* BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure.
59+
*
60+
* During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to
61+
* match the font structure.
62+
*
63+
* BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability
64+
* to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by
65+
* processing the font texture in an image editor, applying fills and any other effects required.
66+
*
67+
* To create multi-line text insert \r, \n or \r\n escape codes into the text string.
68+
*
69+
* To create a BitmapText data files you need a 3rd party app such as:
70+
*
71+
* BMFont (Windows, free): http://www.angelcode.com/products/bmfont/
72+
* Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner
73+
* Littera (Web-based, free): http://kvazars.com/littera/
74+
*
75+
* For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of
76+
* converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson
5977
*
6078
* @class BitmapText
6179
* @extends Phaser.GameObjects.GameObject

src/gameobjects/bitmaptext/static/BitmapTextFactory.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,26 @@ var GameObjectFactory = require('../../GameObjectFactory');
99

1010
/**
1111
* Creates a new Bitmap Text Game Object and adds it to the Scene.
12+
*
13+
* BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure.
14+
*
15+
* During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to
16+
* match the font structure.
17+
*
18+
* BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability
19+
* to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by
20+
* processing the font texture in an image editor, applying fills and any other effects required.
21+
*
22+
* To create multi-line text insert \r, \n or \r\n escape codes into the text string.
23+
*
24+
* To create a BitmapText data files you need a 3rd party app such as:
25+
*
26+
* BMFont (Windows, free): http://www.angelcode.com/products/bmfont/
27+
* Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner
28+
* Littera (Web-based, free): http://kvazars.com/littera/
29+
*
30+
* For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of
31+
* converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson
1232
*
1333
* Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser.
1434
*

src/gameobjects/shape/arc/Arc.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@ var Shape = require('../Shape');
1414

1515
/**
1616
* @classdesc
17+
* The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can
18+
* treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling
19+
* it for input or physics. It provides a quick and easy way for you to render this shape in your
20+
* game without using a texture, while still taking advantage of being fully batched in WebGL.
21+
*
22+
* This shape supports both fill and stroke colors.
23+
*
24+
* When it renders it displays an arc shape. You can control the start and end angles of the arc,
25+
* as well as if the angles are winding clockwise or anti-clockwise. With the default settings
26+
* it renders as a complete circle. By changing the angles you can create other arc shapes,
27+
* such as half-circles.
28+
*
29+
* Arcs also have an `iterations` property and corresponding `setIterations` method. This allows
30+
* you to control how smooth the shape renders in WebGL, by controlling the number of iterations
31+
* that take place during construction.
1732
*
1833
* @class Arc
1934
* @extends Phaser.GameObjects.Shape

src/gameobjects/shape/arc/ArcFactory.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ var GameObjectFactory = require('../../GameObjectFactory');
1111
* Creates a new Arc Shape Game Object and adds it to the Scene.
1212
*
1313
* Note: This method will only be available if the Arc Game Object has been built into Phaser.
14+
*
15+
* The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can
16+
* treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling
17+
* it for input or physics. It provides a quick and easy way for you to render this shape in your
18+
* game without using a texture, while still taking advantage of being fully batched in WebGL.
19+
*
20+
* This shape supports both fill and stroke colors.
21+
*
22+
* When it renders it displays an arc shape. You can control the start and end angles of the arc,
23+
* as well as if the angles are winding clockwise or anti-clockwise. With the default settings
24+
* it renders as a complete circle. By changing the angles you can create other arc shapes,
25+
* such as half-circles.
1426
*
1527
* @method Phaser.GameObjects.GameObjectFactory#arc
1628
* @since 3.13.0

src/gameobjects/shape/ellipse/Ellipse.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@ var Shape = require('../Shape');
1212

1313
/**
1414
* @classdesc
15+
* The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can
16+
* treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling
17+
* it for input or physics. It provides a quick and easy way for you to render this shape in your
18+
* game without using a texture, while still taking advantage of being fully batched in WebGL.
19+
*
20+
* This shape supports both fill and stroke colors.
21+
*
22+
* When it renders it displays an ellipse shape. You can control the width and height of the ellipse.
23+
* If the width and height match it will render as a circle. If the width is less than the height,
24+
* it will look more like an egg shape.
25+
*
26+
* The Ellipse shape also has a `smoothness` property and corresponding `setSmoothness` method.
27+
* This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations
28+
* that take place during construction. Increase and decrease the default value for smoother, or more
29+
* jagged, shapes.
1530
*
1631
* @class Ellipse
1732
* @extends Phaser.GameObjects.Shape

src/gameobjects/shape/ellipse/EllipseFactory.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ var GameObjectFactory = require('../../GameObjectFactory');
1111
* Creates a new Ellipse Shape Game Object and adds it to the Scene.
1212
*
1313
* Note: This method will only be available if the Ellipse Game Object has been built into Phaser.
14+
*
15+
* The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can
16+
* treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling
17+
* it for input or physics. It provides a quick and easy way for you to render this shape in your
18+
* game without using a texture, while still taking advantage of being fully batched in WebGL.
19+
*
20+
* This shape supports both fill and stroke colors.
21+
*
22+
* When it renders it displays an ellipse shape. You can control the width and height of the ellipse.
23+
* If the width and height match it will render as a circle. If the width is less than the height,
24+
* it will look more like an egg shape.
25+
*
26+
* The Ellipse shape also has a `smoothness` property and corresponding `setSmoothness` method.
27+
* This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations
28+
* that take place during construction. Increase and decrease the default value for smoother, or more
29+
* jagged, shapes.
1430
*
1531
* @method Phaser.GameObjects.GameObjectFactory#ellipse
1632
* @since 3.13.0

src/gameobjects/text/static/Text.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,28 @@ var TextStyle = require('../TextStyle');
1818

1919
/**
2020
* @classdesc
21-
* [description]
21+
* A Text Game Object.
22+
*
23+
* Text objects work by creating their own internal hidden Canvas and then renders text to it using
24+
* the standard Canvas `fillText` API. It then creates a texture from this canvas which is rendered
25+
* to your game during the render pass.
26+
*
27+
* Because it uses the Canvas API you can take advantage of all the features this offers, such as
28+
* applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts
29+
* loaded externally, such as Google or TypeKit Web fonts.
30+
*
31+
* You can only display fonts that are currently loaded and available to the browser: therefore fonts must
32+
* be pre-loaded. Phaser does not do ths for you, so you will require the use of a 3rd party font loader,
33+
* or have the fonts ready available in the CSS on the page in which your Phaser game resides.
34+
*
35+
* See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts
36+
* across mobile browsers.
37+
*
38+
* A note on performance: Every time the contents of a Text object changes, i.e. changing the text being
39+
* displayed, or the style of the text, it needs to remake the Text canvas, and if on WebGL, re-upload the
40+
* new texture to the GPU. This can be an expensive operation if used often, or with large quantities of
41+
* Text objects in your game. If you run into performance issues you would be better off using Bitmap Text
42+
* instead, as it benefits from batching and avoids expensive Canvas API calls.
2243
*
2344
* @class Text
2445
* @extends Phaser.GameObjects.GameObject

src/gameobjects/text/static/TextFactory.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,29 @@ var GameObjectFactory = require('../../GameObjectFactory');
99

1010
/**
1111
* Creates a new Text Game Object and adds it to the Scene.
12+
*
13+
* A Text Game Object.
14+
*
15+
* Text objects work by creating their own internal hidden Canvas and then renders text to it using
16+
* the standard Canvas `fillText` API. It then creates a texture from this canvas which is rendered
17+
* to your game during the render pass.
18+
*
19+
* Because it uses the Canvas API you can take advantage of all the features this offers, such as
20+
* applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts
21+
* loaded externally, such as Google or TypeKit Web fonts.
22+
*
23+
* You can only display fonts that are currently loaded and available to the browser: therefore fonts must
24+
* be pre-loaded. Phaser does not do ths for you, so you will require the use of a 3rd party font loader,
25+
* or have the fonts ready available in the CSS on the page in which your Phaser game resides.
26+
*
27+
* See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts
28+
* across mobile browsers.
29+
*
30+
* A note on performance: Every time the contents of a Text object changes, i.e. changing the text being
31+
* displayed, or the style of the text, it needs to remake the Text canvas, and if on WebGL, re-upload the
32+
* new texture to the GPU. This can be an expensive operation if used often, or with large quantities of
33+
* Text objects in your game. If you run into performance issues you would be better off using Bitmap Text
34+
* instead, as it benefits from batching and avoids expensive Canvas API calls.
1235
*
1336
* Note: This method will only be available if the Text Game Object has been built into Phaser.
1437
*

0 commit comments

Comments
 (0)