Object x,y on an infinite map


(David Frank) #1

Hi,

I am parsing the JSON export of snapshot 2018.03.21, but couldn’t quite figure out how x,y value for objects are used within an infinite map. What are they relative to? Do I have to iterate through all chunks and figure out the current boundary?

An example:

                {
                 "height":160,
                 "id":2,
                 "name":"",
                 "properties":[
                        {
                         "name":"TestObjectProp",
                         "type":"string",
                         "value":"Hello Object"
                        }],
                 "rotation":0,
                 "type":"rectangle",
                 "visible":true,
                 "width":160,
                 "x":-192,
                 "y":-1088
                }, 

But my test map’s boundary should be quite small:

Basically I have no idea about the bounds of “objectgroup” layer, as it’s not specified in export/doc.

Thx!


(David Frank) #2

OK I think I got it: object x/y still share the same origin as the map, which is the same origin as chunk’s x/y value.

The only difference is object x/y are in pixels, while chunk’s x/y are in tiles.

This makes things easier than I previously thought.