Skip to content

Commit 0368473

Browse files
committed
The SetFrame method now has two optional arguments: updateSize and updateOrigin (both true by default) which will update the size and origin of the Game Object respectively. Fix phaserjs#3339
1 parent 33cbb06 commit 0368473

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* Calling `setText` on a BitmapText object will now recalculate its display origin values. Fix #3350 (thanks @migiyubi)
2626
* You can now pass an object to Loader.atlas, like you you can with images. Fix #3268 (thanks @TCatshoek)
2727
* The `onContextRestored` callback won't be defined any more unless the WebGL Renderer is in use in the following objects: BitmapMask, Static Tilemap, TileSprite and Text. This should allow those objects to now work in HEADLESS mode. Fix #3368 (thanks @16patsle)
28+
* The SetFrame method now has two optional arguments: `updateSize` and `updateOrigin` (both true by default) which will update the size and origin of the Game Object respectively. Fix #3339 (thanks @Jerenaux)
2829

2930
## Version 3.2.0 - Kaori - 5th March 2018
3031

src/gameobjects/components/Texture.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,16 @@ var Texture = {
6868
* @since 3.0.0
6969
*
7070
* @param {string|integer} frame - The name or index of the frame within the Texture.
71+
* @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object?
72+
* @param {boolean} [updateOrigin=true] - Should this call adjust the origin of the Game Object?
7173
*
7274
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
7375
*/
74-
setFrame: function (frame)
76+
setFrame: function (frame, updateSize, updateOrigin)
7577
{
78+
if (updateSize === undefined) { updateSize = true; }
79+
if (updateOrigin === undefined) { updateOrigin = true; }
80+
7681
this.frame = this.texture.get(frame);
7782

7883
if (!this.frame.cutWidth || !this.frame.cutHeight)
@@ -84,12 +89,12 @@ var Texture = {
8489
this.renderFlags |= _FLAG;
8590
}
8691

87-
if (this._sizeComponent)
92+
if (this._sizeComponent && updateSize)
8893
{
8994
this.setSizeToFrame();
9095
}
9196

92-
if (this._originComponent)
97+
if (this._originComponent && updateOrigin)
9398
{
9499
if (this.frame.customPivot)
95100
{

0 commit comments

Comments
 (0)