pub struct Layer {
pub name: String,
pub is_hidden: bool,
pub sprites: Vec<Sprite>,
pub tag_index: HashMap<String, usize>,
pub render_index: Vec<(usize, i32)>,
pub render_weight: i32,
}Expand description
A Layer contains a set of Sprites stored in a vector. Sprites can be accessed via offset in the vector or by tag in the hashmap.
Fields§
§name: String§sprites: Vec<Sprite>§tag_index: HashMap<String, usize>§render_index: Vec<(usize, i32)>§render_weight: i32Implementations§
Source§impl Layer
impl Layer
pub fn new(name: &str) -> Self
pub fn active(&mut self)
pub fn deactive(&mut self)
pub fn get_max_size(&self) -> PointU16
pub fn add(&mut self, ts: Sprite, tag: &str)
Sourcepub fn add_auto(&mut self, ts: Sprite)
pub fn add_auto(&mut self, ts: Sprite)
Add sprite with auto-generated tag (for backward compatibility)
pub fn get(&mut self, name: &str) -> &mut Sprite
Sourcepub fn with_sprites<F, R>(&mut self, tags: &[&str], f: F) -> R
pub fn with_sprites<F, R>(&mut self, tags: &[&str], f: F) -> R
Execute a closure with multiple sprites simultaneously
This method allows you to work with multiple sprites at once. Panics if any tags are duplicated.
§Safety
Uses unsafe code internally but ensures safety by checking for duplicate indices.
pub fn get_immut(&self, name: &str) -> &Sprite
pub fn set_weight(&mut self, name: &str, w: i32)
pub fn update_render_index(&mut self)
Sourcepub fn render_all_to_buffer(
&mut self,
am: &mut AssetManager,
buffer: &mut Buffer,
)
pub fn render_all_to_buffer( &mut self, am: &mut AssetManager, buffer: &mut Buffer, )
Render all sprites to buffer by merging their content Scene::draw controls which layers should call this method
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Layer
impl RefUnwindSafe for Layer
impl Send for Layer
impl Sync for Layer
impl Unpin for Layer
impl UnsafeUnpin 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
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more