Struct gemini_engine::elements::ascii::AnimatedSprite
source · pub struct AnimatedSprite {
pub pos: Vec2D,
pub frames: Vec<String>,
pub current_frame: usize,
pub modifier: Modifier,
pub align: TextAlign2D,
}Expand description
The AnimatedSprite struct contains a list of Strings into which it indexes based on its current_frame property. You can cycle through frames with the AnimatedSprite::next_frame() function
Fields§
§pos: Vec2DThe position from which the animated sprite will be drawn from
frames: Vec<String>A collection of frames - ACII textures to be displayed by the AnimatedSprite
current_frame: usizeThe current frame being displayed. This will index directly into frames
modifier: ModifierA raw Modifier, determining the appearance of the AnimatedSprite
align: TextAlign2DHow the Sprite should align to the position
Implementations§
source§impl AnimatedSprite
impl AnimatedSprite
sourcepub fn new(pos: Vec2D, frames: &[&str], modifier: Modifier) -> Self
pub fn new(pos: Vec2D, frames: &[&str], modifier: Modifier) -> Self
Create a new AnimatedSprite struct. All newlines at the beginning of each texture will be removed
sourcepub fn next_frame(&mut self)
pub fn next_frame(&mut self)
Go to the next frame of the AnimatedSprite’s frames. Will automatically wrap around at the end of the list
sourcepub fn is_within_frame_range(&self) -> bool
pub fn is_within_frame_range(&self) -> bool
Returns true if the current_frame property is within range of the list of frames. Also returns false if the list of frames is empty
Trait Implementations§
source§impl ViewElement for AnimatedSprite
impl ViewElement for AnimatedSprite
source§fn active_pixels(&self) -> Vec<Pixel>
fn active_pixels(&self) -> Vec<Pixel>
Pixels - A ColChar. If your whole object is a solid colour, consider using utils::points_to_pixels() which will add the same ColChar to every point and can then be used as this function’s outputsource§fn active_points(&self) -> Vec<Vec2D>
fn active_points(&self) -> Vec<Vec2D>
ViewElement occupies, essentially active_pixels() without the ColChars. This has a default setting that extracts the Vec2Ds from active_pixels but you can set it to something else to make it faster