pub struct Layer {
pub tileset: u8,
pub collision: u8,
pub offset: (i32, i32),
pub scroll: (f32, f32),
pub wrap: (bool, bool),
pub visible: bool,
pub opacity: f32,
pub tile_dimensions: (u16, u16),
pub sublayers: Vec<SubLayer>,
pub sublayer_link: SubLayerLink,
/* private fields */
}Expand description
A single layer of a tilemap.
Fields§
§tileset: u8Index of the tileset of this layer.
collision: u8Index of the collision of this layer.
offset: (i32, i32)The XY position offset of this layer.
scroll: (f32, f32)The XY scroll of this layer.
wrap: (bool, bool)Which axes among XY this layer wraps on.
visible: boolWhether the layer is visible.
opacity: f32Opacity of this layer.
tile_dimensions: (u16, u16)Dimensions of the tiles in this layer.
sublayers: Vec<SubLayer>The sublayers of this layer. Any more than 255 sublayers will not be saved.
sublayer_link: SubLayerLinkThe sublayer link of this layer.
Implementations§
Source§impl Layer
impl Layer
Sourcepub fn resize(&mut self, width: u32, height: u32)
pub fn resize(&mut self, width: u32, height: u32)
Resize the layer, filling empty tiles with the tile default (0xFFFF).
If the width is changed, this will reallocate the data buffer!
Sourcepub fn add_sublayer(&mut self, default_value: &[u8]) -> &mut SubLayer
pub fn add_sublayer(&mut self, default_value: &[u8]) -> &mut SubLayer
Add a new sublayer to the layer, returning a mutable reference to it.
Sourcepub fn get(&self, (x, y): (usize, usize)) -> Option<&Tile>
pub fn get(&self, (x, y): (usize, usize)) -> Option<&Tile>
Get a tile by position. Returns None if out of bounds
Sourcepub fn get_mut(&mut self, (x, y): (usize, usize)) -> Option<&mut Tile>
pub fn get_mut(&mut self, (x, y): (usize, usize)) -> Option<&mut Tile>
Get a tile by position, mutably. Returns None if out of bounds
Trait Implementations§
Source§impl IntoIterator for Layer
impl IntoIterator for Layer
impl StructuralPartialEq for Layer
Auto Trait Implementations§
impl Freeze for Layer
impl RefUnwindSafe for Layer
impl Send for Layer
impl Sync for Layer
impl Unpin for Layer
impl UnwindSafe for Layer
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