Skip to content

Commit 887e0d8

Browse files
authored
Merge pull request phaserjs#5302 from samme/feature/copyPosition
Add Phaser.GameObjects.Components.Transform#copyPosition
2 parents 34e1d6b + ad0c5ad commit 887e0d8

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/gameobjects/components/Transform.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,26 @@ var Transform = {
279279
return this;
280280
},
281281

282+
/**
283+
* Copies an object's coordinates to this Game Object's position.
284+
*
285+
* @method Phaser.GameObjects.Components.Transform#copyPosition
286+
* @since 3.50.0
287+
*
288+
* @param {(Phaser.Types.Math.Vector2Like|Phaser.Types.Math.Vector3Like|Phaser.Types.Math.Vector4Like)} source - An object with numeric 'x', 'y', 'z', or 'w' properties. Undefined values are not copied.
289+
*
290+
* @return {this} This Game Object instance.
291+
*/
292+
copyPosition: function (source)
293+
{
294+
if (source.x !== undefined) { this.x = source.x; }
295+
if (source.y !== undefined) { this.y = source.y; }
296+
if (source.z !== undefined) { this.z = source.z; }
297+
if (source.w !== undefined) { this.w = source.w; }
298+
299+
return this;
300+
},
301+
282302
/**
283303
* Sets the position of this Game Object to be a random position within the confines of
284304
* the given area.

0 commit comments

Comments
 (0)