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: Vec2D

The 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: usize

The current frame being displayed. This will index directly into frames

§modifier: Modifier

A raw Modifier, determining the appearance of the AnimatedSprite

§align: TextAlign2D

How the Sprite should align to the position

Implementations§

source§

impl AnimatedSprite

source

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

source

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

source

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

source§

fn active_pixels(&self) -> Vec<Pixel>

Return a vector of the element’s 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 output
source§

fn active_points(&self) -> Vec<Vec2D>

Return the positions the 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

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.