Empty params reset to current texture size

If the width and height aren't provided, it resets the body's size to match the current frame of the game object's texture.
This commit is contained in:
tarsupin 2018-07-24 19:53:41 -05:00 committed by GitHub
parent 4c25d12b44
commit 7af6e5477f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1072,6 +1072,7 @@ var Body = new Class({
/**
* Sizes and positions this Body's boundary, as a rectangle.
* Modifies the Body's `offset` if `center` is true (the default).
* Resets the width and height to match current frame, if no width and height provided.
*
* @method Phaser.Physics.Arcade.Body#setSize
* @since 3.0.0
@ -1088,6 +1089,9 @@ var Body = new Class({
var gameObject = this.gameObject;
if(width === undefined) { width = gameObject.frame.data.sourceSize.w; }
if(height === undefined) { height = gameObject.frame.data.sourceSize.h; }
this.sourceWidth = width;
this.sourceHeight = height;