Jump to content

Need explanation about toGlobal and toLocal


Recommended Posts

Hi guys,


I'm a bit lost when it comes to compute/convert coordinates from one Sprite into another Sprite coordinates system using methods like toGlobal and toLocal. I think I need a a little help on this one in order to get all that stuff clear into my head.


Let's say I have a group with the following structure  - How can I compute Sprite C coordinates into Sprite E coordinate system for example ?


group G

|_Sprite A

|  |_Sprite B

|    |_Sprite C


|_Sprite D

  |_Sprite E


I would try something like : 


Sprite C.toLocal(new Phaser.Point(0,0),Sprite E));


But the result it's wrong so I guess this is not the way to do.


Thank you.

Link to comment
Share on other sites

  • 4 months later...

Can anybody help this guy? :)

I need to transform the pointer position to the group's local. How I can use toLocal/toGlobal for this?


Usually I do through this:


var locX = globalX + group.x;

var locY = globalY + group.y;


But what can I do if the group has rotation and scale?



Seems that I find the way:

var locPos = group.toLocal(pointer, group);
Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...