Struct tego::Map [−][src]
pub struct Map {
pub version: Version,
pub editor_version: Option<Version>,
pub orientation: Orientation,
pub renderorder: Renderorder,
pub size: ivec2,
pub tile_size: ivec2,
pub tilesets: Vec<TileSet>,
pub layers: Vec<Layer>,
}Expand description
Fields
version: Versioneditor_version: Option<Version>orientation: Orientationrenderorder: Renderordersize: ivec2tile_size: ivec2tilesets: Vec<TileSet>layers: Vec<Layer>The Layers that make up this map. The final map image is rendered by stacking the layers in iteration order.
Implementations
Parse a map from xml data
Fetch the image that belongs to a given GID. Returns the image and the pixel coordinates where the tile image is inside of that image.
Iterate over all the layers in this map recursively. All layers are visited in depth-first pre-order manner. The iterator yields the group layers, as well as all of their sub-layers.
In addition to the layer, a number of “pops” is also returned with each item. This is the number of group layers that was left with this iteration step. Some attributes of group layers affect all containing layers. If those attributes are accumulated in a stack, then the number of pops is the number of elemets to remove from the top of the stack.
Example
Rendering layers under consideration of the group opacity:
let opacities = vec![1.];
for (layer, pops) in map.iter_layers() {
opacities.truncate(opacities.len() - pops);
match layer {
Layer::Group(group) => { opacities.push(opacities.last().unwrap() * group.opacity) },
Layer::Tile(tile) => { render_layer(tile, opacities.last()) }
}
}