Skip to content

Commit 6560f51

Browse files
committed
Added jsdocs and updated change log
1 parent 39c05e4 commit 6560f51

2 files changed

Lines changed: 25 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,20 @@ There is a new Game Object Component called `TextureCrop`. It replaces the Textu
8080
* You can toggle the crop on a Game Object by changing the `isCropped` boolean at any point.
8181
* The crop is automatically re-applied when the texture or frame of a Game Object is changed. If you wish to disable this, turn off the crop before changing the frame.
8282

83+
### BitmapText New Features, Updates and Bug Fixes
84+
85+
* Multi-line BitmapText objects can now be aligned. The constructor has a new argument `align` which can accept either left-aligned (the default), center aligned, or right-aligned. Alignment works by calculating the longest line of text in the object and then offsetting the other lines to match it.
86+
* `BitmapText.setCenterAlign` is a new chainable method to center-align the text.
87+
* `BitmapText.setLeftAlign` is a new chainable method to left-align the text.
88+
* `BitmapText.setRightAlign` is a new chainable method to right-align the text.
89+
* `BitmapText.align` is a new property that holds the alignment of the text.
90+
* `BitmapText.setFont` is a new method that allows you to change the font it is rendering with.
91+
* Internally all of the BitmapText properties have been renamed with an underscore (i.e. `letterSpacing` is now `_letterSpacing`), so as to not change the API, getters and setters for them all have been added.
92+
* Internally there is a new `dirty` flag that tracks if any part of the BitmapText has changed. This is used when getting the BitmapText's bounds object, as used in the renderer for line alignment, and in properties like `width` and `height`. The dirty flag ensures the bounds are only recalculated if something has changed, cutting down on un-necessary calculations.
93+
* `GetBitmapTextSize`, which is used internally in the BitmapText Game Objects, will now produce different bounds from the previous version. Previously, the bounds were tight against the letters in the text. However, this meant the bounds were not properly aligned with the origin of the BitmapText, and consequently you'd get different bounds if the text consisted of different characters. The bounds are now calculated purely based on the glyph data and letter spacing values. This will give a far more consistent overall experience, but it does mean if you were using the bounds to position text previously, you'll need to revisit that code again. See issue #3799 for more details (and to discuss this further if you wish) (thanks @SBCGames)
94+
* `GetBitmapTextSize` and its exposed method `BitmapText.getTextBounds` now factor in the display origin of the BitmapText into the `global` position returned.
95+
* The `BitmapText` WebGL Renderer incorrectly calculated the font scale at very small sizes, causing characters to overlap when they shouldn't. Scale is now applied to the correct component parts in the render code.
96+
8397
### New Features
8498

8599
* `Graphics.fillRoundedRect` will draw a stroked rounded rectangle to a Graphics object. The radius of the corners can be either a number, or an object, allowing you to specify different radius per corner (thanks @TadejZupancic)
@@ -101,7 +115,7 @@ There is a new Game Object Component called `TextureCrop`. It replaces the Textu
101115
* The docs for the Loader `filecomplete` event said that you could listen for a specific file using its type and key, i.e.: `filecomplete-image-monster`, however, the code used an underscore instead of a hyphen. We feel the hyphen looks cleaner, so the Loader code has been updated, meaning you can now use the hyphen version of the event properly (thanks @NokFrt)
102116
* If a Game Object is already being dragged, it cannot be dragged by another pointer (in multi-touch mode) until the original pointer has released it (thanks @rexrainbow)
103117
* Calling `Tween.play` on a tween created via `TweenManager.create` wouldn't actually start playback until the tween was first added to the Tween Manager. Now, calling `play` will have it automatically add itself to the Tween Manager if it's not already in there. Fix #3763 (thanks @pantoninho)
104-
* If the Blitter object has no Bob's to render it will now abort immediately, avoiding several context calls in Canvas mode.
118+
* If the Blitter object has no Bobs to render it will now abort immediately, avoiding several context calls in Canvas mode.
105119
* `Scene.run` will now pass the optional `data` object in all cases, no matter if it's waking, resuming or starting a Scene (thanks @rook2pawn)
106120
* `ScenePlugin.start` and `ScenePlugin.restart` will now always queue the op with the Scene Manager, regardless of the state of the Scene, in order to avoid issues where plugins carry on running for a frame before closing down. Fix #3776 (thanks @jjalonso)
107121
* `Tileset.glTexture` is a new property that maps to the WebGL Texture for the Tileset image. It's used internally by the renderer to avoid expensive object look-ups and is set automatically in the `Tileset.setImage` method.
@@ -111,8 +125,6 @@ There is a new Game Object Component called `TextureCrop`. It replaces the Textu
111125
* The TextureManager Sprite Sheet Parser will now throw a concise console warning if you specify invalid frame sizes that would result in no frames being generated (thanks @andygroff)
112126
* The `Quad` Game Object now has a new `setFrame` method that allows you to change the frame being rendered by the Quad, including using frames that are part of a texture atlas. Fix #3161 (thanks @halgorithm)
113127
* The `ScenePlugin` will now queue all of the following ops with the Scene Manager: `start`, `run`, `pause`, `resume`, `sleep`, `wake`, `switch` and `stop`. This means for all of these calls the Scene Manager will add the call into its queue and process it at the start of the next frame. This fixes #3812 and keeps things more predictable (thanks @Waclaw-I)
114-
* `GetBitmapTextSize`, which is used internally in the BitmapText Game Objects, will now produce different bounds from the previous version. Previously, the bounds were tight against the letters in the text. However, this meant the bounds were not properly aligned with the origin of the BitmapText, and consequently you'd get different bounds if the text consisted of different characters. The bounds are now calculated purely based on the glyph data and letter spacing values. This will give a far more consistent overall experience, but it does mean if you were using the bounds to position text previously, you'll need to revisit that code again. See issue #3799 for more details (and to discuss this further if you wish) (thanks @SBCGames)
115-
* `GetBitmapTextSize` and its exposed method `BitmapText.getTextBounds` now factor in the display origin of the BitmapText into the `global` position returned.
116128

117129
### Bug Fixes
118130

@@ -136,7 +148,6 @@ There is a new Game Object Component called `TextureCrop`. It replaces the Textu
136148
* `clearMask(true)` would throw an exception if the Game Object didn't have a mask. Now it checks first before destroying the mask. Fix #3809 (thanks @NokFrt)
137149
* In the WebGL `GeometryMask` the stencil has been changed from `INVERT` to `KEEP` in order to fix issues when masking Graphics objects and other complex objects. Fix #3807. This also fixes the issue where children in Containers would display incorrectly outside of a Geometry mask. Fix #3746 (thanks @zilbuz @oklar)
138150
* `BitmapMask.destroy` will now remove the textures and framebuffers that it created from the WebGL Renderer as part of the destroy process. Fix #3771 (thanks @nunof07)
139-
* The `BitmapText` WebGL Renderer incorrectly calculated the font scale at very small sizes, causing characters to overlap when they shouldn't. Scale is now applied to the correct component parts in the render code.
140151

141152
### Examples, Documentation and TypeScript
142153

src/gameobjects/bitmaptext/static/BitmapText.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ var BitmapText = new Class({
313313
},
314314

315315
/**
316-
* Set the content of this BitmapText.
316+
* Set the textual content of this BitmapText.
317317
*
318-
* An array of strings will be converted multi-line text.
318+
* An array of strings will be converted into multi-line text. Use the align methods to change multi-line alignment.
319319
*
320320
* @method Phaser.GameObjects.BitmapText#setText
321321
* @since 3.0.0
@@ -357,6 +357,8 @@ var BitmapText = new Class({
357357
* Local size is based on just the font size and a [0, 0] position.
358358
*
359359
* Global size takes into account the Game Object's scale, world position and display origin.
360+
*
361+
* Also in the object is data each the length of each line, should this be a multi-line BitmapText.
360362
*
361363
* @method Phaser.GameObjects.BitmapText#getTextBounds
362364
* @since 3.0.0
@@ -380,7 +382,10 @@ var BitmapText = new Class({
380382
},
381383

382384
/**
383-
* TODO
385+
* Changes the font this BitmapText is using to render.
386+
*
387+
* The new texture is loaded and applied to the BitmapText. The existing test, size and alignment are preserved,
388+
* unless overridden via the arguments.
384389
*
385390
* @method Phaser.GameObjects.BitmapText#setFont
386391
* @since 3.11.0
@@ -407,6 +412,8 @@ var BitmapText = new Class({
407412
this._fontSize = size;
408413
this._align = align;
409414

415+
this.setTexture(entry.texture, entry.frame);
416+
410417
GetBitmapTextSize(this, false, this._bounds);
411418
}
412419
}

0 commit comments

Comments
 (0)