Tiled maps

The cocos.tiles module provides a simple method of managing tiled displays in 2D games.

Tile maps are made of three components:

images
Images are from individual files for from image atlases in a single file.
tiles
Tiles may be stand-alone or part of a TileSet.
maps
MapLayers are made of either rectangular or hexagonal Cells which reference the tiles used to draw the cell.

cocos.tiles supports two file formats:

  1. The TMX file format as generated by the Tiled map editor from <http://mapeditor.org>
  2. An internal cocos2d XML format that it can both read and write described below in The XML File Specification

Both file formats are loaded with the same API call:

#This loads a TMX format map
cocos.tiles.load('filename.tmx')

#This loads a cocos2d XML format map
cocos.tiles.load('filename.xml')

Once the map is loaded the API for accessing the map information is the same regardless of the on-disk format.

Fairly simple examples of using the cocos.tiles module is provided in test/test_tiles.py and test/test_tmx.py

A basic tile map editor is provided in tools/editor.py