|
| 1 | +/** |
| 2 | +* @author Richard Davey <rich@photonstorm.com> |
| 3 | +* @copyright 2016 Photon Storm Ltd. |
| 4 | +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} |
| 5 | +*/ |
| 6 | + |
| 7 | +Phaser.GameObjects.BitmapText.FACTORY_KEY = 'bitmapText'; |
| 8 | + |
| 9 | +/** |
| 10 | +* Create a new BitmapText object. |
| 11 | +* |
| 12 | +* BitmapText objects work by taking a texture file and an XML file that describes the font structure. |
| 13 | +* It then generates a new Sprite object for each letter of the text, proportionally spaced out and aligned to |
| 14 | +* match the font structure. |
| 15 | +* |
| 16 | +* BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability |
| 17 | +* to use Web Fonts. However you trade this flexibility for pure rendering speed. You can also create visually compelling BitmapTexts by |
| 18 | +* processing the font texture in an image editor first, applying fills and any other effects required. |
| 19 | +* |
| 20 | +* To create multi-line text insert \r, \n or \r\n escape codes into the text string. |
| 21 | +* |
| 22 | +* To create a BitmapText data files you can use: |
| 23 | +* |
| 24 | +* BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ |
| 25 | +* Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner |
| 26 | +* Littera (Web-based, free): http://kvazars.com/littera/ |
| 27 | +* |
| 28 | +* @method Phaser.GameObjects.Factory#bitmapText |
| 29 | +* @param {number} x - X coordinate to display the BitmapText object at. |
| 30 | +* @param {number} y - Y coordinate to display the BitmapText object at. |
| 31 | +* @param {string} font - The key of the BitmapText as stored in Phaser.Cache. |
| 32 | +* @param {string} [text=''] - The text that will be rendered. This can also be set later via BitmapText.text. |
| 33 | +* @param {number} [size=32] - The size the font will be rendered at in pixels. |
| 34 | +* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group. |
| 35 | +* @return {Phaser.BitmapText} The newly created bitmapText object. |
| 36 | +*/ |
| 37 | +Phaser.GameObjects.BitmapText.FACTORY_ADD = function (x, y, font, text, size, group) { |
| 38 | + |
| 39 | + if (group === undefined) { group = this.world; } |
| 40 | + |
| 41 | + return group.add(new Phaser.GameObjects.BitmapText(this.game, x, y, font, text, size)); |
| 42 | + |
| 43 | +}; |
| 44 | + |
| 45 | +Phaser.GameObjects.BitmapText.FACTORY_MAKE = function (x, y, font, text, size) { |
| 46 | + |
| 47 | + return new Phaser.GameObjects.BitmapText(this.game, x, y, font, text, size)); |
| 48 | + |
| 49 | +}; |
0 commit comments