@@ -4,28 +4,29 @@ Cross-platform Tiled map parsing utilities.
44
55## Nugets
66[ ![ ] ( Docs/Images/nuget.png ) TiledLib] ( https://www.nuget.org/packages/TiledLib/ ) - Core library, everything you need to read Tiled maps/tilesets.
7- [ ![ ] ( Docs/Images/nuget.png ) TiledLib.Pipeline] ( https://www.nuget.org/packages/TiledLib.Pipeline/ ) - MonoGame content pipeline extension, provides a ContentImporter for Tiled maps.
7+ [ ![ ] ( Docs/Images/nuget.png ) TiledLib.Pipeline] ( https://www.nuget.org/packages/TiledLib.Pipeline/ ) - MonoGame content pipeline extension, provides a ContentImporter for Tiled maps.
8+ If you add a ContentProcessor, you will be able to map the output of the supplied importer to custom classes tailored specifically for your game.
89
910## Basic usecase
1011``` csharp
1112using (var stream = File .OpenRead (filename ))
1213{
13- var map = Map .FromStream (stream , ts => File .OpenRead (Path .Combine (Path .GetDirectoryName (filename ), ts .source )));
14+ var map = Map .FromStream (stream , ts => File .OpenRead (Path .Combine (Path .GetDirectoryName (filename ), ts .Source )));
1415
15- foreach (var layer in map .Layers .OfType <TileLayer >())
16- {
17- for (int y = 0 , i = 0 ; y < layer .Height ; y ++ )
18- for (int x = 0 ; x < layer .Width ; x ++ , i ++ )
19- {
20- var gid = layer .data [i ];
21- if (gid == 0 )
22- continue ;
16+ foreach (var layer in map .Layers .OfType <TileLayer >())
17+ {
18+ for (int y = 0 , i = 0 ; y < layer .Height ; y ++ )
19+ for (int x = 0 ; x < layer .Width ; x ++ , i ++ )
20+ {
21+ var gid = layer .data [i ];
22+ if (gid == 0 )
23+ continue ;
2324
24- var tileset = map .Tilesets .Single (ts => gid >= ts .firstgid && ts .firstgid + ts .TileCount > gid );
25- var tile = tileset [gid ];
25+ var tileset = map .Tilesets .Single (ts => gid >= ts .FirstGid && ts .FirstGid + ts .TileCount > gid );
26+ var tile = tileset [gid ];
2627
27- // Do stuff with the tile.
28- }
29- }
28+ // Do stuff with the tile.
29+ }
30+ }
3031}
3132```
0 commit comments