Skip to content

Commit 5085ed5

Browse files
committed
Added setOriginFromFrame.
1 parent 3422569 commit 5085ed5

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

src/gameobjects/components/Origin.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,29 @@ var Origin = {
112112
return this.updateDisplayOrigin();
113113
},
114114

115+
/**
116+
* Sets the origin of this Game Object based on the Pivot values in its Frame.
117+
*
118+
* @method Phaser.GameObjects.Components.Origin#setOriginFromFrame
119+
* @since 3.0.0
120+
*
121+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
122+
*/
123+
setOriginFromFrame: function ()
124+
{
125+
if (!this.frame || !this.frame.customPivot)
126+
{
127+
return this.setOrigin();
128+
}
129+
else
130+
{
131+
this.originX = this.frame.pivotX;
132+
this.originY = this.frame.pivotY;
133+
}
134+
135+
return this.updateDisplayOrigin();
136+
},
137+
115138
/**
116139
* Sets the display origin of this Game Object.
117140
* The difference between this and setting the origin is that you can use pixel values for setting the display origin.

0 commit comments

Comments
 (0)