06. Creating Entities from Tiles


So far we’ve looked at how to create tile maps and have them display in game. We’ve also used these tile maps to create collision. This guide shows how to instantiate entities by placing tiles in a tile map (no code required).

Creating an Entity

Any type of entity can be created through tile maps providing lots of flexibility. For this example we’ll create a simple entity which displays a yellow rectangle called Monster:

  1. Select the Quick Actions tab in Glue and click Add Entity

  2. Name the entity Monster
  3. Check the AxisAlignedRectangle check box
  4. Leave the other options default and click OK

We need to modify the rectangle so it stands out relative to the collision rectangles:

  1. Select the newly-created rectangle (named AxisAlignedRectangleInstance)
  2. Change Width to 12
  3. Change Height to 12
  4. Change Color to Yellow

Defining Monster Tiles

We will be using the Type property to set the entity type. For a deeper dive on how this property works, see the Type documentation here: http://flatredball.com/documentation/tools/tiled-plugin/using-tiled-object-types/

The documentation linked above shows how to import an XML file created by Glue so that variables defined on Monster (or any other entity) automatically appear in Tiled. For simplicity we’ll skip this step, but you may want to perform that additional step for larger projects.

To set the Type property:

  1. Open whichever level is currently being loaded in your game in Tiled (such as Level2Map.tmx)
  2. Select the TiledIcons. We should always use TiledIcons to create entities rather than visual tilesets like dungeonTileSet
  3. Click the Edit Tileset button

  4. Select a tile on your map to represent the monsters. For example, select the red monster icon.

  5. Enter the entity name Monster as the Type for this tile. Note that the name needs to match the entity name exactly, including capitalization

Placing Monster Tiles

Any tiles placed with the Type of Monster will create Monster instances at runtime. Tiles for creating entities are placed just like any other tiles. We can place a few monster tiles in either level.


As always, don’t forget to save your changes on the tile map and tile set.

If we run our game, we will see the monster enemies (yellow rectangles).



If enemies aren’t showing up, check the following:

  • Make sure that Level2Tmx.tmx and dungeonTileSet.tsx files have both been saved
  • Verify that you entered the right name (including capitalization) in the Type property.