Page 1 of 1

tiles coordinates

Posted: 22 Apr 2013, 09:33
by radiateur
Hi, i need to get the tiles coordinates to display the skins dialog bubbles, i searched the forum and the doc for this, but i don't know why the solutions i read just doesn't give me the good coordinates.

I tried this :

in the classe Mapinteraction manager i have this :

Code: Select all

if (evt.type == MapInteractionEvent.SKIN_CLICK)
         {
            
            var tile:Tile = skin.parent.parent as Tile;
            MyGlobal.clickedPnjName = skin.name;
            MyGlobal.clickedTile = tile;
            main.logTrace("le nom de la skin est : " + skin.name);
            main.logTrace("global var tile : " + tile); //here i set a constant var for the tile clicked, the trace gives me the good tile name...
            var localXcoordinates:Number = Number(tile.x);
            var localYcoordinates:Number = Number(tile.y);
            
            main.logTrace("Tile local coordinates = " + localXcoordinates+","+localYcoordinates); //but here it trace "Tile local coordinates = 0,0;" But it's not possible...


on the stage object, if i click on a tile

Code: Select all

var point:Point = localToGlobal(new Point(MyGlobal.clickedTile.x, MyGlobal.clickedTile.y)); // but of course this don't work cause the coordinates are not good.


As i found it with trace in the skinclick event, the coordinates founded for the tile are not good.

So, what did i do wrong ??

Re: tiles coordinates

Posted: 22 Apr 2013, 10:14
by Bax
When you first trace the tile coordinates you get 0,0 because those are the coordinates of the tile with respect to the first tile's container.
You have to use the localToGlobal function, but it is not that simple as you show.
You should read the localToGlobal documentation for more informations.

Re: tiles coordinates

Posted: 22 Apr 2013, 11:02
by radiateur
Thanks Bax,

from the flash documentation you mean ?

EDIT : ok i checked the flash doc, i did not used it in the good way as you said.