HaxePunk / tiled

Tiled TMX import for HaxePunk
50 stars 18 forks source link

TmxEntity.hx has a tile loading bug #5

Open infidel- opened 11 years ago

infidel- commented 11 years ago

Line 53: gid = layer.tileGIDs[row][col] - 1;

does not take into account multiple tilesets so "- 1" is accurate only for the first tileset. In other cases we need to offset it by firstGID field of the appropriate tileset instead. The code I came up with is (replacing the line above):

// find proper tileset for this gid var firstGID = 1; for (t in map.tilesets) if (gid >= t.firstGID) firstGID = t.firstGID; gid -= firstGID;

MattTuttle commented 11 years ago

Yeah, multiple tilesets should have better support. I haven't looked into it fully but aren't there cases where map.tilesets need to be populated with the actual bitmap data? Maybe that's just related to width/height.

infidel- commented 11 years ago

I've no idea, I just fixed what was wrong with my test tmx.

stvoidmain commented 10 years ago

In rder for this to work correcty, yes, tileset need to have its image loaded, i have done that and, thanks to it, i made the map to autoload layers and even object layer with images, i used TiledImage for that, using the tileset.image and the getRect method, its working even when map hast multiple tilesets.