TMX Map Format
来源:互联网 发布:linux 获取cpu信息 编辑:程序博客网 时间:2024/06/05 15:20
TMX Map Format
The TMX (Tile Map XML) map format used by Tiled is a flexible way to describe a tile based map. It can describe maps with any tile size, any amount of layers, any number of tile sets and it allows custom properties to be set on most elements. Beside tile layers, it can also contain groups of objects that can be placed freely.
In this document we'll go through each element found in this map format. The elements are mentioned in the headers and the list of attributes of the elements are listed right below, followed by a short explanation. Attributes that are deprecated or unsupported by the current version of Tiled are formatted in italics.
<map>
- version: The TMX format version, generally 1.0.
- orientation: Map orientation. Tiled supports "orthogonal" and "isometric" at the moment.
- width: The map width in tiles.
- height: The map height in tiles.
- tilewidth: The width of a tile.
- tileheight: The height of a tile.
The tilewidth
and tileheight
properties determine the general grid size of the map. The individual tiles may have different sizes. Larger tiles will extend at the top and right (anchored to the bottom left).
Can contain: properties, tileset, layer, objectgroup
<tileset>
- firstgid: The first global tile ID of this tileset (this global ID maps to the first tile in this tileset).
- source: If this tileset is stored in an external TSX (Tile Set XML) file, this attribute refers to that file.
- name: The name of this tileset.
- tilewidth: The (maximum) width of the tiles in this tileset.
- tileheight: The (maximum) height of the tiles in this tileset.
- spacing: The spacing in pixels between the tiles in this tileset (applies to the tileset image).
- margin: The margin around the tiles in this tileset (applies to the tileset image).
Can contain: image, tile
<image>
- format: To be used when embedding images. Deprecated and unsupported in Tiled Qt.
- id: Used by some versions of Tiled Java. Deprecated and unsupported by Tiled Qt.
- source: The reference to the tileset image file (Tiled supports most common image formats).
- trans: Defines a specific color that is treated as transparent (example value: "FF00FF" for magenta).
As of the current version of Tiled Qt, each tileset has a single image associated with it, which is cut into smaller tiles based on the attributes defined on the tileset element. Later versions may add support for adding multiple images to a single tileset, as is possible in Tiled Java.
<tile>
- id: The local tile ID within its tileset.
Can contain: properties, image
<layer>
- name: The name of the layer.
- x: The x coordinate of the layer in tiles. Defaults to 0 and can no longer be changed in Tiled Qt.
- y: The y coordinate of the layer in tiles. Defaults to 0 and can no longer be changed in Tiled Qt.
- width: The width of the layer in tiles. Traditionally required, but as of Tiled Qt always the same as the map width.
- height: The height of the layer in tiles. Traditionally required, but as of Tiled Qt always the same as the map height.
- opacity: The opacity of the layer as a value from 0 to 1. Defaults to 1.
- visible: Whether the layer is shown (1) or hidden (0). Defaults to 1.
Can contain: properties, data
<data>
- encoding: The encoding used to encode the tile layer data. When used, it can be "base64" and "csv" at the moment.
- compression: The compression used to compress the tile layer data. Tiled Qt supports "gzip" and "zlib".
When no encoding or compression is given, the tiles are stored as individual XML tile
elements. Next to that, the easiest format to parse is the "csv" (comma separated values) format. The base64-encoded compressed layer data is somewhat explained in Examining the map format.
Can contain: tile
<tile>
- gid: The global tile ID.
Not to be confused with the tile
element inside a tileset
, this element defines the value of a single tile on a tile layer. This is however the most inefficient way of storing the tile layer data, and should generally be avoided.
Can contain: properties, image
<objectgroup>
- name: The name of the object group.
- x: The x coordinate of the object group in tiles. Defaults to 0 and can no longer be changed in Tiled Qt.
- y: The y coordinate of the object group in tiles. Defaults to 0 and can no longer be changed in Tiled Qt.
- width: The width of the object group in tiles. Meaningless.
- height: The height of the object group in tiles. Meaningless.
The object group is in fact a map layer, and is hence called "object layer" in Tiled Qt.
Can contain: object
<object>
- name: The name of the object. An arbitrary string.
- type: The type of the object. An arbitrary string.
- x: The x coordinate of the object in pixels.
- y: The y coordinate of the object in pixels.
- width: The width of the object in pixels.
- height: The height of the object in pixels.
- gid: An reference to a tile (optional).
While tile layers are very suitable for anything repetitive aligned to the tile grid, sometimes you want to annotate your map with other information, not necessarily aligned to the grid. Hence the objects have their coordinates and size in pixels, but you can still easily align that to the grid when you want to.
You generally use objects to add custom information to your tile map, such as spawn points, warps, exits, etc.
When the object has a gid
set, then it is represented by the image of the tile with that global ID. Currently that means width
and height
are ignored for such objects. The image alignment currently depends on the map orientation. In orthogonal orientation it's aligned to the bottom-left while in isometric it's aligned to the bottom-center.
Can contain: properties, image
<properties>
Can contain: property
Wraps any number of custom properties. Can be used as a child of the map
, tile
(when part of a tileset
), layer
, objectgroup
and object
elements.
<property>
- name: The name of the property.
- value: The value of the property.
When the property spans contains newlines, the current versions of Tiled Java and Tiled Qt will write out the value as characters contained inside the property
element rather than as the value
attribute. However, it is at the moment not really possible to edit properties consisting of multiple lines with Tiled.
It is possible that a future version of the TMX format will switch to always saving property values inside the element rather than as an attribute.
- TMX Map Format
- [译]在Tiled Map中使用碰撞检测(二) TMX地图中的碰撞检测
- cocos2d-x 读取tmx文件报错 TMXTiledMap: Map not found. Please check the filename
- [译]在Tiled Map中使用碰撞检测(二) TMX地图中的碰撞检测
- Tile map tmx加载出错m_uMaxGID >= m_pTileSet->m_uFirstGid与资源放置
- TMX使用
- TMX API
- tmx格式
- TMX地图格式
- TMX Tilemaps & Box2D Fixtures
- TMX 高清模式
- TMX Retina Display
- (译)TMX地图格式
- cocos2dx 地图 Atlas Tmx
- 使用tmx地图
- TMX地图格式
- cocos2dx TMX地图
- cocos2dx TMX地图
- 通过经纬度计算地球两点间的距离
- WebRequest 模拟请求登录 终于搞定了!
- c#中textbox只能输入数字, 包括小数
- 【编程语言】Android--如何创建sdcard,向sdcard里面传送图片,更改sd卡权限
- 字符串查找算法之(一)KMP算法
- TMX Map Format
- Crystal Reports 2008 安装错误处理
- 中文路径问题
- JAVA读取文件,避免中文乱码
- JAVA读取文件,避免中文乱码
- svn status-显示工作副本中目录与文件的状态
- WCF技术的不同应用场景及其实现分析(续)
- orcad 小问题两个(annotate 标号重复和显示GND的方法)
- Liferay配置文件Tag标签参考