The LayeredTileMap object is the runtime type for the TMX file format (the native file format for Tiled).

Adding a TMX file to a Screen results in a MapDrawableBatch being created in generated code.

The LayeredTileMap represents a collection of MapDrawableBatches. It contains one MapDrawableBatch per layer in the source TMX file.

The LayeredTileMap class inherits from FlatRedBall.PositionedObject so it can be moved and attached to other PositionedObjects. Each MapDrawableBatch is attached to its parent LayeredTileMap, and can be moved independently by changing its RelativePosition.

Adding a MapDrawableBatch From TMX to a Screen

To add a LayeredTileMap from an existing TMX:

  1. Create a TMX file in Tiled
  2. Save the TMX file in a location relative to your game’s content folder. Be sure that all PNG files and TSX files (tileset files) are also relative to the game content folder
  3. Create a game screen
  4. Drag+drop the TMX file into your Screen’s Files folder

No additional code is necessary – your map will now show up in the screen.


LayeredTileMap as a list of MapDrawableBatches

The LayeredTileMap is mostly a List of MapDrawableBatches. For example, you can print out information about a MapDrawableBatch as follows:

string information = "This map has " + TestLevel.MapLayers.Count + " layers\n";

foreach (var layer in TestLevel.MapLayers)
    information += "Number of verts: " + layer.Vertices.Length + "\n";