From 107ca71d6b90442c27fa939af334e52c856000ba Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 3 May 2018 15:52:12 +0100 Subject: [PATCH] BitmapText, both static and dynamic, can now take any data-type, including numbers, for the `text` argument in the constructor. Before they only worked via `setText` --- CHANGELOG.md | 1 + src/gameobjects/bitmaptext/dynamic/DynamicBitmapText.js | 4 +++- src/gameobjects/bitmaptext/static/BitmapText.js | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6ca9c491..cdecaadcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,7 @@ The Loader has been given an overhaul to improve its performance and extensibili * ScenePlugin.setActive would only toggle the current Scene, not any given Scene. * ScenePlugin.setVisible would only toggle the current Scene, not any given Scene. * The Graphics Creator would automatically add the Graphics to the display list by mistake. The default should be to remain hidden. Fix #3637 (thanks @mikuso) +* BitmapText, both static and dynamic, can now take any data-type, including numbers, for the `text` argument in the constructor. Before they only worked via `setText` (thanks @Jelaw21) ### Examples, Documentation and TypeScript diff --git a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapText.js b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapText.js index 568472cd0..adc222312 100644 --- a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapText.js +++ b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapText.js @@ -111,7 +111,7 @@ var DynamicBitmapText = new Class({ * @type {string} * @since 3.0.0 */ - this.text = (Array.isArray(text)) ? text.join('\n') : text; + this.text = ''; /** * [description] @@ -132,6 +132,8 @@ var DynamicBitmapText = new Class({ */ this.letterSpacing = 0; + this.setText(text); + this.setTexture(entry.texture, entry.frame); this.setPosition(x, y); this.setOrigin(0, 0); diff --git a/src/gameobjects/bitmaptext/static/BitmapText.js b/src/gameobjects/bitmaptext/static/BitmapText.js index e617470c0..1dacf2138 100644 --- a/src/gameobjects/bitmaptext/static/BitmapText.js +++ b/src/gameobjects/bitmaptext/static/BitmapText.js @@ -121,7 +121,7 @@ var BitmapText = new Class({ * @type {string} * @since 3.0.0 */ - this.text = (Array.isArray(text)) ? text.join('\n') : text; + this.text = ''; /** * [description] @@ -142,6 +142,8 @@ var BitmapText = new Class({ */ this.letterSpacing = 0; + this.setText(text); + this.setTexture(entry.texture, entry.frame); this.setPosition(x, y); this.setOrigin(0, 0);