Skip to content

Commit 562344f

Browse files
committed
The ComputedSize Component now has setSize and setDisplaySize methods. This component is used for Game Objects that have a non-texture based size.
1 parent fba8183 commit 562344f

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ being passed to the simulation. The default value is 1 to remain consistent with
3434
* BaseSound `setRate` and `setDetune` from the 3.3.0 release have moved to the WebAudioSound and HTML5AudioSound classes respectively, as they each handle the values differently.
3535
* The file `InteractiveObject.js` has been renamed to `CreateInteractiveObject.js` to more accurately reflect what it does and to avoid type errors in the docs.
3636
* Renamed the Camera Controls module exports for `Fixed` to `FixedKeyControl` and `Smoothed` to `SmoothedKeyControl` to match the class names. Fix #3463 (thanks @seivan)
37+
* The ComputedSize Component now has `setSize` and `setDisplaySize` methods. This component is used for Game Objects that have a non-texture based size.
3738

3839

3940

src/gameobjects/components/ComputedSize.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
/**
8-
* Provides methods used for setting the blend mode of a Game Object.
8+
* Provides methods used for calculating and setting the size of a non-Frame based Game Object.
99
* Should be applied as a mixin and not used directly.
1010
*
1111
* @name Phaser.GameObjects.Components.ComputedSize
@@ -74,6 +74,45 @@ var ComputedSize = {
7474
this.scaleY = value / this.height;
7575
}
7676

77+
},
78+
79+
/**
80+
* Sets the size of this Game Object.
81+
*
82+
* @method Phaser.GameObjects.Components.ComputedSize#setSize
83+
* @since 3.4.0
84+
*
85+
* @param {number} width - The width of this Game Object.
86+
* @param {number} height - The height of this Game Object.
87+
*
88+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
89+
*/
90+
setSize: function (width, height)
91+
{
92+
this.width = width;
93+
this.height = height;
94+
95+
return this;
96+
},
97+
98+
/**
99+
* Sets the display size of this Game Object.
100+
* Calling this will adjust the scale.
101+
*
102+
* @method Phaser.GameObjects.Components.ComputedSize#setDisplaySize
103+
* @since 3.4.0
104+
*
105+
* @param {number} width - The width of this Game Object.
106+
* @param {number} height - The height of this Game Object.
107+
*
108+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
109+
*/
110+
setDisplaySize: function (width, height)
111+
{
112+
this.displayWidth = width;
113+
this.displayHeight = height;
114+
115+
return this;
77116
}
78117

79118
};

0 commit comments

Comments
 (0)