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:
Richard Davey 2020-08-03 17:54:29 +01:00
parent edf074ba47
commit 111a4e1ce2

View file

@ -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
* 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.
*
*
* This shape supports both fill and stroke colors.
*
*
* You can change the size of the rectangle by changing the `width` and `height` properties.
*
* @class Rectangle
@ -65,6 +65,37 @@ var Rectangle = new Class({
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.
*