File tree 1 file changed +50
-0
lines changed
src/gameobjects/bitmaptext/static
1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -852,6 +852,34 @@ var BitmapText = new Class({
852
852
return this ;
853
853
} ,
854
854
855
+ /**
856
+ * Sets the display size of this BitmapText Game Object.
857
+ *
858
+ * Calling this will adjust the scale.
859
+ *
860
+ * @method Phaser.GameObjects.BitmapText#setDisplaySize
861
+ * @since 3.61.0
862
+ *
863
+ * @param {number } width - The width of this BitmapText Game Object.
864
+ * @param {number } height - The height of this BitmapText Game Object.
865
+ *
866
+ * @return {this } This Game Object instance.
867
+ */
868
+ setDisplaySize : function ( displayWidth , displayHeight )
869
+ {
870
+ this . setScale ( 1 , 1 ) ;
871
+
872
+ this . getTextBounds ( false ) ;
873
+
874
+ var scaleX = displayWidth / this . width ;
875
+
876
+ var scaleY = displayHeight / this . height ;
877
+
878
+ this . setScale ( scaleX , scaleY ) ;
879
+
880
+ return this ;
881
+ } ,
882
+
855
883
/**
856
884
* Controls the alignment of each line of text in this BitmapText object.
857
885
*
@@ -1069,6 +1097,17 @@ var BitmapText = new Class({
1069
1097
*/
1070
1098
displayWidth : {
1071
1099
1100
+ set : function ( value )
1101
+ {
1102
+ this . setScaleX ( 1 ) ;
1103
+
1104
+ this . getTextBounds ( false ) ;
1105
+
1106
+ var scale = value / this . width ;
1107
+
1108
+ this . setScaleX ( scale ) ;
1109
+ } ,
1110
+
1072
1111
get : function ( )
1073
1112
{
1074
1113
return this . width ;
@@ -1090,6 +1129,17 @@ var BitmapText = new Class({
1090
1129
*/
1091
1130
displayHeight : {
1092
1131
1132
+ set : function ( value )
1133
+ {
1134
+ this . setScaleY ( 1 ) ;
1135
+
1136
+ this . getTextBounds ( false ) ;
1137
+
1138
+ var scale = value / this . height ;
1139
+
1140
+ this . setScaleY ( scale ) ;
1141
+ } ,
1142
+
1093
1143
get : function ( )
1094
1144
{
1095
1145
return this . height ;
You can’t perform that action at this time.
0 commit comments