原文链接 http://doc.mapeditor.org/en/latest/manual/layers/
初稿2017-10-15,还待完善
术语对照:
- Layer - 图层
- Object - 对象
图层
Tiled地图支持多种内容(content),这些内容(content)放在在许多不同的图层中。最常见的图层是Tiled图层和对象图层。还有一个Image图层,用来将单一的前景/背景图片放入到地图中。图层的顺序决定了内容的渲染顺序。
图层可以设置为“不可见”,“部分可见”。图层也可以被“锁定”。图层也有“偏移”。(这句话不是很懂。。。 “位移”可以用来将不同图层之间进行定位,比如模拟深度。)
眼睛图标和锁图标显示了各图层的可见性和锁定状态。
可以用Group图层来组织各图层的层次关系。这样在存在大量图层的情况下非常有用。
Tile图层
Tile图层提供了一种用存储Tile数据的方法,TIle数据用来填充大面积区域。Tile数据是简单的数组,只包含了Tile的索引,因此每个位置不能存储额外的信息。仅有的额外信息是少量的标志位,这些标志位允许图形的垂直平铺,水平或者反对角翻转(用于支持90度增量旋转)。
渲染每个Tile层所需的信息与地图一起储存。该地图基于方向和其他属性来指定Tile的位置和渲染顺序。
尽管只能够引用tile,tile层也可用于定义您级别中的各种非图形信息。 通常可以使用特殊的tile set来传达碰撞信息,并且任何类型的不需要自定义属性并且始终与网格对齐的对象也可以被放置在瓦片层上。
Object Layer 对象层
Oject 层非常有用,因为对象可以存储很多中 Tile 层不能存储的信息。
Objects 可以自由摆放,缩放,旋转。他们可以有独立的自定义属性。
目前有很多Objects:
- Rectangle - 用来定义矩形区域
- Ellipse - 用来定义椭圆或者圆形区域
- Polygon (多边形) - for when a rectangle or ellipse doesn’t cut it (often a collision area)
- Polyline (折线) - 可以用来作为跟随的路性或者碰撞的墙。
- Tile - 用来自由放置,缩放或者旋转你的Tile图形。
- Text - 自定义文本或者注释(Tiled 1.0起开始支持)。
所有Objects都可以被命名。在这种情况下,他们的名字可以在他们上访的标签中显示(默认只有选中的Objects)。Objects可以被指定一种类型,这非常有用,因为可以给予类型去指定标签的颜色和可用的自定义属性。对于Tile Objects来说,类型可以从他们的Tile继承。
对于大多数地图类型来说,Objects是基于像素去定位的。唯一的例外是 Isometric地图(不是isometric staggered).对于isometri地图来说,他们的位置被存储在投影坐标中。如果你在等距游戏中为对象使用不同的坐标空间,则需要对应的转换这些坐标。
Object的宽和高也基本上基于像素储存。Isometric地图不懂。。。。
Image 层
Image层提供了一种在地图中包含单一前景/背景图片的快速方法。当前还作用不大,因为如果你将图片作为Tilesets加入,并放在Tile Objects, 你可以自由的缩放和旋转图片。
使用Image层的唯一优点是避免在使用“选择对象”工具时选择/拖动图像。 但是,从Tiled 1.1版本起,也可以通过锁定包含要避免交互的图块对象的对象层来实现。
Group Layers
Group 层类似于文件夹的形式,可以用来将各层组织起来。当地图中包含大量的图层时,这个功能较为有用。
Group层的可见性,透明图,偏移和锁定属性会应用于所有的子层。
可以使用鼠标将图层轻松地拖入group中。 提升层/下层动作还允许移动层进出组。
Layers can be easily dragged in and out of groups with the mouse. The Raise Layer / Lower Layer actions also allow moving layers in and out of groups.
未来的功能
层可以有更多强大的功能:
- 能够锁定单个物体.
- Moving certain map-global properties to the Tile Layer (#149). It would be useful if one map could accommodate layers of different tile sizes and maybe even of different orientation.
如果您喜欢任何这些计划,请通过成为顾客来帮助我更快地到达这个计划。 我得到的支持越多,我可以花更多的时间来改善Tiled!
英文原文如下,供参考
Working with Layers
A Tiled map supports various sorts of content, and this content is organized into various different layers. The most common layers are the Tile Layer and the Object Layer. There is also an Image Layer for including simple foreground or background graphics. The order of the layers determines the rendering order of your content.
Layers can be hidden, made only partially visible and can be locked. Layers also have an offset, which can be used to position them independently of each other, for example to fake depth.
Layers View
The eye and lock icon toggle the visibility and locked state of a layer respectively.
You use Group Layers to organize the layers into a hierarchy. This makes it more comfortable to work with a large amount of layers.
Tile Layers
Tile layers provide an efficient way of storing a large area filled with tile data. The data is a simple array of tile references and as such no additional information can be stored for each location. The only extra information stored are a few flags, that allow tile graphics to be flipped vertically, horizontally or anti-diagonally (to support rotation in 90-degree increments).
The information needed to render each tile layer is stored with the map, which specifies the position and rendering order of the tiles based on the orientation and various other properties.
Despite only being able to refer to tiles, tile layers can also be useful for defining various bits of non-graphical information in your level. Collision information can often be conveyed using a special tileset, and any kind of object that does not need custom properties and is always aligned to the grid can also be placed on a tile layer.
Object Layers
Object layers are useful because they can store many kinds of information that would not fit in a tile layer. Objects can be freely positioned, resized and rotated. They can also have individual custom properties. There are many kinds of objects:
Rectangle - for marking custom rectangular areas
Ellipse - for marking custom ellipse or circular areas
Polygon - for when a rectangle or ellipse doesn’t cut it (often a collision area)
Polyline - can be a path to follow or a wall to collide with
Tile - for freely placing, scaling and rotating your tile graphics
Text - for custom text or notes (since Tiled 1.0)
All objects can be named, in which case their name will show up in a label above them (by default only for selected objects). Objects can also be given a type, which is useful since it can be used to customize the color of their label and the available custom properties for this object type. For tile objects, the type can be inherited from their tile.
For most map types, objects are positioned in plain pixels. The only exception to this are isometric maps (not isometric staggered). For isometric maps, it was deemed useful to store their positions in a projected coordinate space. For this, the isometric tiles are assumed to represent projected squares with both sides equal to the tile height. If you’re using a different coordinate space for objects in your isometric game, you’ll need to convert these coordinates accordingly.
The object width and height is also mostly stored in pixels. For isometric maps, all shape objects (rectangle, ellipse, polygon and polyline) are projected into the same coordinate space described above. This is based on the assumption that these objects are generally used to mark areas on the map.
Image Layers
Image layers provide a way to quickly include a single image as foreground or background of your map. They are currently not so useful, because if you instead add the image as a Tileset and place it as a Tile Object, you gain the ability to freely scale and rotate the image.
The only advantage of using an image layer is that it avoids selecting / dragging the image while using the Select Objects tool. However, since Tiled 1.1 this can also be achieved by locking the object layer containing the tile object you’d like to avoid interacting with.
New in Tiled 1.0
Group Layers
Group layers work like folders and can be used for organizing the layers into a hierarchy. This is mainly useful when your map contains a large amount of layers.
The visibility, opacity, offset and lock of a group layer affects all child layers.
Layers can be easily dragged in and out of groups with the mouse. The Raise Layer / Lower Layer actions also allow moving layers in and out of groups.
Future Extensions
There are many ways in which the layers can be made more powerful:
Ability to lock individual objects (#828).
Moving certain map-global properties to the Tile Layer (#149). It would be useful if one map could accommodate layers of different tile sizes and maybe even of different orientation.
If you like any of these plans, please help me getting around to it faster by becoming a patron. The more support I receive the more time I can afford to spend improving Tiled!