Skip to content

Commit 5fa4264

Browse files
committed
Added new Transform.getParentRotation method
1 parent 3be81dc commit 5fa4264

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/gameobjects/components/Transform.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,32 @@ var Transform = {
491491
}
492492

493493
return tempMatrix;
494+
},
495+
496+
/**
497+
* Gets the sum total rotation of all of this Game Objects parent Containers.
498+
*
499+
* The returned value is in radians and will be zero if this Game Object has no parent container.
500+
*
501+
* @method Phaser.GameObjects.Components.Transform#getParentRotation
502+
* @since 3.18.0
503+
*
504+
* @return {number} The sum total rotation, in radians, of all parent containers of this Game Object.
505+
*/
506+
getParentRotation: function ()
507+
{
508+
var rotation = 0;
509+
510+
var parent = this.parentContainer;
511+
512+
while (parent)
513+
{
514+
rotation += parent.rotation;
515+
516+
parent = parent.parentContainer;
517+
}
518+
519+
return rotation;
494520
}
495521

496522
};

0 commit comments

Comments
 (0)