File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed
src/gameobjects/bitmaptext/static Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -855,6 +855,34 @@ var BitmapText = new Class({
855855 return this ;
856856 } ,
857857
858+ /**
859+ * Sets the display size of this BitmapText Game Object.
860+ *
861+ * Calling this will adjust the scale.
862+ *
863+ * @method Phaser.GameObjects.Components.Size#setDisplaySize
864+ * @since 3.61.0
865+ *
866+ * @param {number } width - The width of this BitmapText Game Object.
867+ * @param {number } height - The height of this BitmapText Game Object.
868+ *
869+ * @return {this } This Game Object instance.
870+ */
871+ setDisplaySize : function ( displayWidth , displayHeight )
872+ {
873+ this . setScale ( 1 , 1 ) ;
874+
875+ this . getTextBounds ( false ) ;
876+
877+ var scaleX = displayWidth / this . width ;
878+
879+ var scaleY = displayHeight / this . height ;
880+
881+ this . setScale ( scaleX , scaleY ) ;
882+
883+ return this ;
884+ } ,
885+
858886 /**
859887 * Controls the alignment of each line of text in this BitmapText object.
860888 *
@@ -1072,6 +1100,17 @@ var BitmapText = new Class({
10721100 */
10731101 displayWidth : {
10741102
1103+ set : function ( value )
1104+ {
1105+ this . setScaleX ( 1 ) ;
1106+
1107+ this . getTextBounds ( false ) ;
1108+
1109+ var scale = value / this . width ;
1110+
1111+ this . setScaleX ( scale ) ;
1112+ } ,
1113+
10751114 get : function ( )
10761115 {
10771116 return this . width ;
@@ -1093,6 +1132,17 @@ var BitmapText = new Class({
10931132 */
10941133 displayHeight : {
10951134
1135+ set : function ( value )
1136+ {
1137+ this . setScaleY ( 1 ) ;
1138+
1139+ this . getTextBounds ( false ) ;
1140+
1141+ var scale = value / this . height ;
1142+
1143+ this . setScaleY ( scale ) ;
1144+ } ,
1145+
10961146 get : function ( )
10971147 {
10981148 return this . height ;
You can’t perform that action at this time.
0 commit comments