mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 05:33:35 +00:00
Calling Rectangle.setSize()
wouldn't change the underlying geometry of the Shape Game Object, causing any stroke to be incorrectly rendered after a size change.
This commit is contained in:
parent
edf074ba47
commit
111a4e1ce2
1 changed files with 33 additions and 2 deletions
|
@ -15,9 +15,9 @@ var RectangleRender = require('./RectangleRender');
|
||||||
* treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling
|
* treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling
|
||||||
* it for input or physics. It provides a quick and easy way for you to render this shape in your
|
* it for input or physics. It provides a quick and easy way for you to render this shape in your
|
||||||
* game without using a texture, while still taking advantage of being fully batched in WebGL.
|
* game without using a texture, while still taking advantage of being fully batched in WebGL.
|
||||||
*
|
*
|
||||||
* This shape supports both fill and stroke colors.
|
* This shape supports both fill and stroke colors.
|
||||||
*
|
*
|
||||||
* You can change the size of the rectangle by changing the `width` and `height` properties.
|
* You can change the size of the rectangle by changing the `width` and `height` properties.
|
||||||
*
|
*
|
||||||
* @class Rectangle
|
* @class Rectangle
|
||||||
|
@ -65,6 +65,37 @@ var Rectangle = new Class({
|
||||||
this.updateData();
|
this.updateData();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the internal size of this Game Object, as used for frame or physics body creation.
|
||||||
|
*
|
||||||
|
* This will not change the size that the Game Object is rendered in-game.
|
||||||
|
* For that you need to either set the scale of the Game Object (`setScale`) or call the
|
||||||
|
* `setDisplaySize` method, which is the same thing as changing the scale but allows you
|
||||||
|
* to do so by giving pixel values.
|
||||||
|
*
|
||||||
|
* If you have enabled this Game Object for input, changing the size will _not_ change the
|
||||||
|
* size of the hit area. To do this you should adjust the `input.hitArea` object directly.
|
||||||
|
*
|
||||||
|
* @method Phaser.GameObjects.Rectangle#setSize
|
||||||
|
* @since 3.13.0
|
||||||
|
*
|
||||||
|
* @param {number} width - The width of this Game Object.
|
||||||
|
* @param {number} height - The height of this Game Object.
|
||||||
|
*
|
||||||
|
* @return {this} This Game Object instance.
|
||||||
|
*/
|
||||||
|
setSize: function (width, height)
|
||||||
|
{
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
|
||||||
|
this.geom.setSize(width, height);
|
||||||
|
|
||||||
|
this.updateData();
|
||||||
|
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal method that updates the data and path values.
|
* Internal method that updates the data and path values.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue