Skip to content

Commit 1623449

Browse files
authored
Merge pull request phaserjs#3863 from tarsupin/patch-2
Empty params reset to current texture size
2 parents 5033eb0 + 79d64ab commit 1623449

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/physics/arcade/Body.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,7 @@ var Body = new Class({
10721072
/**
10731073
* Sizes and positions this Body's boundary, as a rectangle.
10741074
* Modifies the Body's `offset` if `center` is true (the default).
1075+
* Resets the width and height to match current frame, if no width and height provided.
10751076
*
10761077
* @method Phaser.Physics.Arcade.Body#setSize
10771078
* @since 3.0.0
@@ -1088,6 +1089,9 @@ var Body = new Class({
10881089

10891090
var gameObject = this.gameObject;
10901091

1092+
if (width === undefined) { width = gameObject.frame.data.sourceSize.w; }
1093+
if (height === undefined) { height = gameObject.frame.data.sourceSize.h; }
1094+
10911095
this.sourceWidth = width;
10921096
this.sourceHeight = height;
10931097

src/physics/arcade/StaticBody.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,8 @@ var StaticBody = new Class({
486486
},
487487

488488
/**
489-
* [description]
489+
* Sets the size of the body.
490+
* Resets the body to match the current frame if no width or height is provided.
490491
*
491492
* @method Phaser.Physics.Arcade.StaticBody#setSize
492493
* @since 3.0.0
@@ -500,6 +501,8 @@ var StaticBody = new Class({
500501
*/
501502
setSize: function (width, height, offsetX, offsetY)
502503
{
504+
if (width === undefined) { width = this.gameObject.frame.data.sourceSize.w; }
505+
if (height === undefined) { height = this.gameObject.frame.data.sourceSize.h; }
503506
if (offsetX === undefined) { offsetX = this.offset.x; }
504507
if (offsetY === undefined) { offsetY = this.offset.y; }
505508

0 commit comments

Comments
 (0)