pub struct Map {
pub source: PathBuf,
pub orientation: Orientation,
pub width: u32,
pub height: u32,
pub tile_width: u32,
pub tile_height: u32,
pub hex_side_length: Option<i32>,
pub stagger_axis: StaggerAxis,
pub stagger_index: StaggerIndex,
pub properties: Properties,
pub background_color: Option<Color>,
pub user_type: Option<String>,
/* private fields */
}Expand description
All Tiled map files will be parsed into this. Holds all the layers and tilesets.
Fields§
§source: PathBufThe path first used in a ResourceReader to load this map.
orientation: OrientationThe way tiles are laid out in the map.
width: u32Width of the map, in tiles.
§Note
There is no guarantee that this value will be the same as the width from its tile layers.
height: u32Height of the map, in tiles.
§Note
There is no guarantee that this value will be the same as the height from its tile layers.
tile_width: u32Tile width, in pixels.
§Note
This value along with Self::tile_height determine the general size of the map, and
individual tiles may have different sizes. As such, there is no guarantee that this value
will be the same as the one from the tilesets the map is using.
tile_height: u32Tile height, in pixels.
§Note
This value along with Self::tile_width determine the general size of the map, and
individual tiles may have different sizes. As such, there is no guarantee that this value
will be the same as the one from the tilesets the map is using.
hex_side_length: Option<i32>The length of the side of a hexagonal tile in pixels (used by tile layers on hexagonal maps).
stagger_axis: StaggerAxisThe stagger axis of Hexagonal/Staggered map.
stagger_index: StaggerIndexThe stagger index of Hexagonal/Staggered map.
properties: PropertiesThe custom properties of this map.
background_color: Option<Color>The background color of this map, if any.
user_type: Option<String>The type of the map, which is arbitrary and set by the user.
Implementations§
Source§impl Map
impl Map
Sourcepub fn version(&self) -> &str
pub fn version(&self) -> &str
The TMX format version this map was saved to. Equivalent to the map file’s version
attribute.
Sourcepub fn infinite(&self) -> bool
pub fn infinite(&self) -> bool
Whether this map is infinite. An infinite map has no fixed size and can grow in all
directions. Its layer data is stored in chunks. This value determines whether the map’s
tile layers are FiniteTileLayers or crate::InfiniteTileLayers.
Source§impl Map
impl Map
Sourcepub fn layers(&self) -> impl ExactSizeIterator<Item = Layer<'_>>
pub fn layers(&self) -> impl ExactSizeIterator<Item = Layer<'_>>
Get an iterator over top-level layers in the map in ascending order of their layer index.
Note: “top-level” means that if a map has layers of LayerDataType::Group type, you
need to recursively enumerate those group layers.
§Example
let tile_layers = map.layers().filter_map(|layer| match layer.layer_type() {
tiled::LayerType::Tiles(layer) => Some(layer),
_ => None,
});
for layer in tile_layers {
my_renderer.render(layer);
}