tiles coordinates

Post here your questions about the OpenSpace 2.x or notify bugs and suggestions.

Moderators: Lapo, Bax

radiateur
Posts: 62
Joined: 15 Aug 2011, 08:14

tiles coordinates

Postby radiateur » 22 Apr 2013, 09:33

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 ??
User avatar
Bax
Site Admin
Posts: 4332
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: tiles coordinates

Postby Bax » 22 Apr 2013, 10:14

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.
Paolo Bax
The SmartFoxServer Team
radiateur
Posts: 62
Joined: 15 Aug 2011, 08:14

Re: tiles coordinates

Postby radiateur » 22 Apr 2013, 11:02

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.

Return to “OpenSpace v2 discussions and help”

Who is online

Users browsing this forum: No registered users and 6 guests