The ComputedSize Component now has setSize and setDisplaySize methods. This component is used for Game Objects that have a non-texture based size.

This commit is contained in:
Richard Davey 2018-03-29 12:55:28 +01:00
parent fba8183d94
commit 562344fed0
2 changed files with 41 additions and 1 deletions

View file

@ -34,6 +34,7 @@ being passed to the simulation. The default value is 1 to remain consistent with
* 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.
* 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.
* Renamed the Camera Controls module exports for `Fixed` to `FixedKeyControl` and `Smoothed` to `SmoothedKeyControl` to match the class names. Fix #3463 (thanks @seivan)
* The ComputedSize Component now has `setSize` and `setDisplaySize` methods. This component is used for Game Objects that have a non-texture based size.

View file

@ -5,7 +5,7 @@
*/
/**
* Provides methods used for setting the blend mode of a Game Object.
* Provides methods used for calculating and setting the size of a non-Frame based Game Object.
* Should be applied as a mixin and not used directly.
*
* @name Phaser.GameObjects.Components.ComputedSize
@ -74,6 +74,45 @@ var ComputedSize = {
this.scaleY = value / this.height;
}
},
/**
* Sets the size of this Game Object.
*
* @method Phaser.GameObjects.Components.ComputedSize#setSize
* @since 3.4.0
*
* @param {number} width - The width of this Game Object.
* @param {number} height - The height of this Game Object.
*
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
*/
setSize: function (width, height)
{
this.width = width;
this.height = height;
return this;
},
/**
* Sets the display size of this Game Object.
* Calling this will adjust the scale.
*
* @method Phaser.GameObjects.Components.ComputedSize#setDisplaySize
* @since 3.4.0
*
* @param {number} width - The width of this Game Object.
* @param {number} height - The height of this Game Object.
*
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
*/
setDisplaySize: function (width, height)
{
this.displayWidth = width;
this.displayHeight = height;
return this;
}
};