[][src]Struct rs_tiled_json::map::Map

pub struct Map {
    pub orientation: MapOrientation,
    pub height: u16,
    pub width: u16,
    pub nextobjectid: u32,
    pub nextlayerid: u16,
    pub tileheight: u16,
    pub tilewidth: u16,
    pub tiledversion: String,
    pub backgroundcolor: Option<Color>,
    pub renderorder: RenderOrder,
    pub hexsidelength: u16,
    pub staggeraxis: Option<StaggerAxis>,
    pub staggerindex: Option<StaggerIndex>,
    pub tilesets: Vec<Tileset>,
    pub layers: Vec<Layer>,
    pub properties: Vec<Property>,
}

The primary structure of all modules.

Fields

orientation: MapOrientationheight: u16width: u16nextobjectid: u32nextlayerid: u16tileheight: u16tilewidth: u16tiledversion: Stringbackgroundcolor: Option<Color>renderorder: RenderOrderhexsidelength: u16staggeraxis: Option<StaggerAxis>staggerindex: Option<StaggerIndex>tilesets: Vec<Tileset>layers: Vec<Layer>properties: Vec<Property>

Methods

impl Map[src]

pub fn layers(&self) -> &Vec<Layer>[src]

Borrow the layers vector.

This is useful for loading arbitrary game data; you will just iterate through each layer and utilize the appropriate data.

Most would be more interested in get_layer_by_name().

pub fn layer_by_name(&self, name: &str) -> Option<&Layer>[src]

Use this to grab a layer by name.

This is particularly useful when you know what kinds of data you need to pick up.

Maps might have three static layers describing the scenery; I might name them LAYER_GROUND, LAYER_FLOOR, LAYER_SKY. I could load the map and the tilesets, grab those tile layers, and get to building my internal representation.

pub fn tilesets(&self) -> &Vec<Tileset>[src]

Borrow the tileset vector.

This is the best way to ensure you have loaded all of the necessary textures into memory and are able to decompose gids into their local id variants.

pub fn tileset_by_gid(&self, gid: u32) -> Option<&Tileset>[src]

Looks for the tileset with the GID provided, automatically stripping any flags present on the GID (flipping horizontally, vertically, etc...)

Do note that no bounds checking is done. If you search for gid: 12352234 and you have one tileset with 1000 tiles, you will still receive that one tileset back. Just be sure the value you send as gid came directly from the map file, tile layer data.

This only returns Option::None when no tilesets exist in the map.

pub fn width(&self) -> u16[src]

Get the map width in tiles.

pub fn height(&self) -> u16[src]

Get the map height in tiles.

pub fn tile_width(&self) -> u16[src]

Get the width of a tile in the map.

pub fn tile_height(&self) -> u16[src]

Get the height of a tile in the map.

pub fn bg_color(&self) -> Option<Color>[src]

Get the background color of the map if specified.

pub fn orientation(&self) -> MapOrientation[src]

Retrieve orientation as variant of MapOrientation.

Can be converted to a string using the method to_string().

pub fn render_order(&self) -> RenderOrder[src]

Retrieve renderorder as variant of RenderOrder. This applies only to Orthogonal Maps but you'll get the default value anyway.

Can be converted to a string using the method to_string().

pub fn hex_side_length(&self) -> u16[src]

Get the hex side length. Hex maps only.

pub fn stagger_axis(&self) -> Option<StaggerAxis>[src]

Get the stagger axis as a variant of StaggerAxis. Useful only to staggered/hexagonal maps, but will still yeild a valid default if you call it irelevantly.

Can be converted to a string using the method to_string()

pub fn stagger_index(&self) -> Option<StaggerIndex>[src]

Get the stagger index as a variant of StaggerIndex. Useful only to staggered/hexagonal maps, but will still yeild a valid default if you call it irelevantly.

Can be converted to a string using the method to_string()

pub fn tiled_version(&self) -> &String[src]

Get the version of tiled the map was compiled with.

Trait Implementations

impl Debug for Map[src]

impl<'de> Deserialize<'de> for Map[src]

impl HasProperty for Map[src]

fn get_property_vector(&self) -> &Vec<Property>[src]

Provide access to property values for Maps

Auto Trait Implementations

impl RefUnwindSafe for Map

impl Send for Map

impl Sync for Map

impl Unpin for Map

impl UnwindSafe for Map

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.