Anderberg Posted April 1, 2014 Share Posted April 1, 2014 Is there any way to get the absolute position of a sprite? I have a group holding several sprites and I want to move one of them. The group will be moved as a whole. The sprite's position is relative to the group, but I would like the position relative to the world, or more precisely, relative to the activePointer.I have tried using physics.arcade methods, such as angleToPointer, but those methods do not take inte account the object's offset, that is its parents' positions (the group's position). Is there any way built into Phaser to accomplish this? Or do I need to iterate over all parents and calculate the absolute position in my own function? Link to comment Share on other sites More sharing options...
rich Posted April 1, 2014 Share Posted April 1, 2014 Sprite.world is a Phaser.Point object that contains the world coordinates of the Sprite, as Sprite.position (as you've found out) contains the position relative to its parent, as does Sprite.x/y. Anderberg 1 Link to comment Share on other sites More sharing options...
Anderberg Posted April 2, 2014 Author Share Posted April 2, 2014 Thank you Rich!Really great work you are doing on the framework, I appreciate it! Link to comment Share on other sites More sharing options...
Samrat Saha Posted January 16, 2017 Share Posted January 16, 2017 Thanks rich, Absolutely Charming and Precise Answer. sprite.world would return a pointer OBJECT. reference below. Link to comment Share on other sites More sharing options...
samme Posted January 16, 2017 Share Posted January 16, 2017 There is also `sprite.worldPosition` and I can never remember the difference. Link to comment Share on other sites More sharing options...
Recommended Posts