Let’s say I have a JSON
export of this map:
{
"compressionlevel": -1,
"height": 200,
"infinite": false,
"layers": [{
"comment": "// snippet out for clarity"
},
{
"draworder": "index",
"id": 4,
"name": "NPCs",
"objects": [{
"class": "",
"gid": 568,
"height": 64,
"id": 21,
"name": "Fred the Town Bum",
"properties": [{
"name": "actions",
"type": "string",
"value": "examine,talk"
},
{
"name": "examine",
"type": "string",
"value": "He stinks."
}
],
"rotation": 0,
"visible": true,
"width": 64,
"x": 4672,
"y": 7680
}
],
"opacity": 1,
"type": "objectgroup",
"visible": true,
"x": 0,
"y": 0
},
{
"draworder": "topdown",
"id": 5,
"name": "Monsters",
"objects": [],
"opacity": 1,
"type": "objectgroup",
"visible": true,
"x": 0,
"y": 0
}
],
"nextlayerid": 6,
"nextobjectid": 29,
"orientation": "orthogonal",
"renderorder": "right-down",
"tiledversion": "1.9.0",
"tileheight": 64,
"tilesets": [{
"firstgid": 1,
"source": "background.tsx"
},
{
"firstgid": 253,
"source": "foreground.tsx"
},
{
"firstgid": 550,
"source": "objects\/Monsters.tsx"
},
{
"firstgid": 568,
"source": "objects\/NPCs.tsx"
}
],
"tilewidth": 64,
"type": "map",
"version": "1.9",
"width": 200
}
As I’m writing my game (in TypeScript), how would I get the X/Y coordinate to snip from the Tileset to paint “Fred the Town Bum” from the NPC tileset. I know it because the gid
is 568 which has the source of "source": "objects\/NPCs.tsx"
. But would it then realize of… get this tileset… clip it at X=n and Y=n.
Basically… how would I get the information from the gid
of the tile in the tileset to clip?