Skip to content

Commit af5b1f2

Browse files
committed
StaticBody.reset in Arcade Physics would ignore the x and y values given to it. If given, they're now used to reset the parent Game Object before the body is updated. Fix phaserjs#4224
1 parent cc55ee7 commit af5b1f2

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ one set of bindings ever created, which makes things a lot cleaner.
231231
* The Texture Tint Pipeline had a logic error that would cause every 2001st quad to either be invisible, or pick-up the texture of the 2000th quad by mistake. The `batchQuad` and `batchTri` methods how handle re-assigning the batch texture if they cause a batch flush as part of their process.
232232
* Rotating Sprites that used a Normal Map wouldn't rotate the normal map with it, causing the lighting effects to become irregular. The normal map vectors are now rotated correctly (thanks @sercant for the PR and @fazzamatazz and @ysraelJMM for the report)
233233
* Changing `scaleX` or `scaleY` on a `MatterImage` or `MatterSprite` would cause the body scale to become distorted as the setters didn't use the correct factor when resetting the initial scale. Fix #4206 (thanks @YannCaron)
234+
* `StaticBody.reset` in Arcade Physics would ignore the `x` and `y` values given to it. If given, they're now used to reset the parent Game Object before the body is updated. Fix #4224 (thanks @samme)
234235

235236
### Examples and TypeScript
236237

src/physics/arcade/StaticBody.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,14 +619,14 @@ var StaticBody = new Class({
619619
},
620620

621621
/**
622-
* Updates this Static Body's position based on the current Game Object it is bound to.
622+
* Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates.
623623
* Similar to `updateFromGameObject`, but doesn't modify the Body's dimensions.
624624
*
625625
* @method Phaser.Physics.Arcade.StaticBody#reset
626626
* @since 3.0.0
627627
*
628-
* @param {number} x - The x coordinate to reset the body to.
629-
* @param {number} y - The y coordinate to reset the body to.
628+
* @param {number} [x] - The x coordinate to reset the body to. If not given will use the parent Game Object's coordinate.
629+
* @param {number} [y] - The y coordinate to reset the body to. If not given will use the parent Game Object's coordinate.
630630
*/
631631
reset: function (x, y)
632632
{
@@ -637,6 +637,8 @@ var StaticBody = new Class({
637637

638638
this.world.staticTree.remove(this);
639639

640+
gameObject.setPosition(x, y);
641+
640642
gameObject.getTopLeft(this.position);
641643

642644
this.updateCenter();

0 commit comments

Comments
 (0)