Text.setText has a new optional argument immediate which will re-create the texture immediately upon call, rather than wait for the next render pass to do so (thanks @Scraft #2594)

This commit is contained in:
Richard Davey 2016-06-27 22:42:01 +01:00
parent b24de1e561
commit a0c771d47e
3 changed files with 28 additions and 11 deletions

View file

@ -330,6 +330,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
* The TilemapParser will now add more data when importing Image object types from Tiled. The extra data available is: image width, image height, and flags to see if the image is flipped either horizontally, vertically or diagonally (thanks @gotenxds #2564 #2554)
* TilemapLayer.renderRegion has had an assignment to the obsolete `tileColor` property removed (thanks @cryptographer #2583)
* Group.getFurthestFrom and Group.getClosestTo has a new optional argument: `callback`. This allows you to apply your own additional filtering to the distance checks, ultimately influencing the selected child (thanks @LoneStranger #2577)
* Text.setText has a new optional argument `immediate` which will re-create the texture immediately upon call, rather than wait for the next render pass to do so (thanks @Scraft #2594)
### Bug Fixes

View file

@ -1250,18 +1250,34 @@ Phaser.Text.prototype.componentsToFont = function (components) {
};
/**
* The text to be displayed by this Text object.
* Use a \n to insert a carriage return and split the text.
* The text will be rendered with any style currently set.
*
* @method Phaser.Text#setText
* @param {string} [text] - The text to be displayed. Set to an empty string to clear text that is already present.
* @return {Phaser.Text} This Text instance.
*/
Phaser.Text.prototype.setText = function (text) {
* The text to be displayed by this Text object.
* Use a \n to insert a carriage return and split the text.
* The text will be rendered with any style currently set.
*
* Use the optional `immediate` argument if you need the Text display to update immediately.
*
* If not it will re-create the texture of this Text object during the next time the render
* loop is called.
*
* @method Phaser.Text#setText
* @param {string} [text] - The text to be displayed. Set to an empty string to clear text that is already present.
* @param {boolean} [immediate=false] - Update the texture used by this Text object immediately (true) or automatically during the next render loop (false).
* @return {Phaser.Text} This Text instance.
*/
Phaser.Text.prototype.setText = function (text, immediate) {
if (immediate === undefined) { immediate = false; }
this.text = text.toString() || '';
this.dirty = true;
if (immediate)
{
this.updateText();
}
else
{
this.dirty = true;
}
return this;

View file

@ -4934,7 +4934,7 @@ declare module Phaser {
renderTabLine(line: string, x: number, y: number, fill?: boolean): void;
setShadow(x?: number, y?: number, color?: any, blur?: number, shadowStroke?: boolean, shadowFill?: boolean): Phaser.Text;
setStyle(style?: PhaserTextStyle, update?: boolean): Phaser.Text;
setText(text: string): Phaser.Text;
setText(text: string, immediate?: boolean): Phaser.Text;
setTextBounds(x?: number, y?: number, width?: number, height?: number): Phaser.Text;
update(): void;
updateFont(components: any): void;