pub enum TileLayer<'map> {
Finite(FiniteTileLayer<'map>),
Infinite(InfiniteTileLayer<'map>),
}
Expand description
A map layer containing tiles in some way. May be finite or infinite.
Variants§
Finite(FiniteTileLayer<'map>)
An finite tile layer; Also see FiniteTileLayer
.
Infinite(InfiniteTileLayer<'map>)
An infinite tile layer; Also see InfiniteTileLayer
.
Implementations§
source§impl<'map> TileLayer<'map>
impl<'map> TileLayer<'map>
sourcepub fn get_tile(&self, x: i32, y: i32) -> Option<LayerTile<'map>>
pub fn get_tile(&self, x: i32, y: i32) -> Option<LayerTile<'map>>
Obtains the tile present at the position given.
If the position given is invalid or the position is empty, this function will return None
.
sourcepub fn width(&self) -> Option<u32>
pub fn width(&self) -> Option<u32>
The width of this layer, if finite, or None
if infinite.
§Example
use tiled::LayerType;
use tiled::Loader;
let width = match layer {
tiled::TileLayer::Finite(finite) => Some(finite.width()),
_ => None,
};
// These are both equal, and they achieve the same thing; However, matching on the layer
// type is significantly more verbose. If you already know the layer type, then it is
// slighly faster to use its respective width method.
assert_eq!(width, layer.width());
sourcepub fn height(&self) -> Option<u32>
pub fn height(&self) -> Option<u32>
The height of this layer, if finite, or None
if infinite.
§Example
use tiled::LayerType;
use tiled::Loader;
let height = match layer {
tiled::TileLayer::Finite(finite) => Some(finite.height()),
_ => None,
};
// These are both equal, and they achieve the same thing; However, matching on the layer
// type is significantly more verbose. If you already know the layer type, then it is
// slighly faster to use its respective height method.
assert_eq!(height, layer.height());
Trait Implementations§
Auto Trait Implementations§
impl<'map> Freeze for TileLayer<'map>
impl<'map> RefUnwindSafe for TileLayer<'map>
impl<'map> Send for TileLayer<'map>
impl<'map> Sync for TileLayer<'map>
impl<'map> Unpin for TileLayer<'map>
impl<'map> UnwindSafe for TileLayer<'map>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more