Added Text.setResolution methods.

This commit is contained in:
Richard Davey 2018-07-18 14:45:10 +01:00
parent 1b9f5dc76d
commit 14ba51d928
3 changed files with 47 additions and 0 deletions

View file

@ -5,6 +5,7 @@
### New Features
* `Camera.resolution` is a new read-only property that holds the current game config resolution that the camera is using. This is used internally for viewport calculations.
* `Text.resolution` and the method `Text.setResolution` allows you to control the resolution of a Static Text Game Object. By default it will be set to match the resolution set in the Game Config, but you can override it yourself via the TextStyle. It allows for much clearer text on High DPI devices, at the cost of larger internal Canvas textures for the Text - so please use with caution, as the more high res Text you have, the more memory it uses up. Fix #3528 (thanks @kirillbunin)
### Updates

View file

@ -687,6 +687,29 @@ var TextStyle = new Class({
return this.update(false);
},
/**
* Set the resolution used by the Text object.
*
* By default it will be set to match the resolution set in the Game Config,
* but you can override it via this method. It allows for much clearer text on High DPI devices,
* at the cost of memory because it uses larger internal Canvas textures for the Text.
*
* Please use with caution, as the more high res Text you have, the more memory it uses up.
*
* @method Phaser.GameObjects.Text.TextStyle#setResolution
* @since 3.12.0
*
* @param {number} value - The resolution for this Text object to use.
*
* @return {Phaser.GameObjects.Text} The parent Text object.
*/
setResolution: function (value)
{
this.resolution = value;
return this.update(false);
},
/**
* Set the stroke settings.
*

View file

@ -853,6 +853,29 @@ var Text = new Class({
return this.style.setAlign(align);
},
/**
* Set the resolution used by this Text object.
*
* By default it will be set to match the resolution set in the Game Config,
* but you can override it via this method, or by specifying it in the Text style configuration object.
*
* It allows for much clearer text on High DPI devices, at the cost of memory because it uses larger
* internal Canvas textures for the Text.
*
* Therefore, please use with caution, as the more high res Text you have, the more memory it uses.
*
* @method Phaser.GameObjects.Text#setResolution
* @since 3.12.0
*
* @param {number} value - The resolution for this Text object to use.
*
* @return {Phaser.GameObjects.Text} This Text object.
*/
setResolution: function (value)
{
return this.style.setResolution(value);
},
/**
* Set the text padding.
*