mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 14:08:28 +00:00
Add setDisplaySize method
This commit is contained in:
parent
cbb802bcff
commit
2241671a61
1 changed files with 50 additions and 0 deletions
|
@ -855,6 +855,34 @@ var BitmapText = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the display size of this BitmapText Game Object.
|
||||
*
|
||||
* Calling this will adjust the scale.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Size#setDisplaySize
|
||||
* @since 3.61.0
|
||||
*
|
||||
* @param {number} width - The width of this BitmapText Game Object.
|
||||
* @param {number} height - The height of this BitmapText Game Object.
|
||||
*
|
||||
* @return {this} This Game Object instance.
|
||||
*/
|
||||
setDisplaySize: function (displayWidth, displayHeight)
|
||||
{
|
||||
this.setScale(1, 1);
|
||||
|
||||
this.getTextBounds(false);
|
||||
|
||||
var scaleX = displayWidth / this.width;
|
||||
|
||||
var scaleY = displayHeight / this.height;
|
||||
|
||||
this.setScale(scaleX, scaleY);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Controls the alignment of each line of text in this BitmapText object.
|
||||
*
|
||||
|
@ -1072,6 +1100,17 @@ var BitmapText = new Class({
|
|||
*/
|
||||
displayWidth: {
|
||||
|
||||
set: function(value)
|
||||
{
|
||||
this.setScaleX(1);
|
||||
|
||||
this.getTextBounds(false);
|
||||
|
||||
var scale = value / this.width;
|
||||
|
||||
this.setScaleX(scale);
|
||||
},
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this.width;
|
||||
|
@ -1093,6 +1132,17 @@ var BitmapText = new Class({
|
|||
*/
|
||||
displayHeight: {
|
||||
|
||||
set: function(value)
|
||||
{
|
||||
this.setScaleY(1);
|
||||
|
||||
this.getTextBounds(false);
|
||||
|
||||
var scale = value / this.height;
|
||||
|
||||
this.setScaleY(scale);
|
||||
},
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this.height;
|
||||
|
|
Loading…
Add table
Reference in a new issue