Struct Scene

Source
pub struct Scene<I: ImageSize> { /* private fields */ }
Expand description

A scene is used to manage sprite’s life and run animation with sprite

Implementations§

Source§

impl<I: ImageSize> Scene<I>

Source

pub fn new() -> Scene<I>

Create a new scene

Source

pub fn event<E>(&mut self, e: &E)
where E: GenericEvent,

Update animation’s state

Source

pub fn draw<B: Graphics<Texture = I>>(&self, t: Matrix2d, b: &mut B)

Render this scene

Source

pub fn draw_tinted<B: Graphics<Texture = I>>( &self, t: Matrix2d, b: &mut B, c: [f32; 3], )

Render this scene with tint

Source

pub fn run(&mut self, sprite_id: Uuid, animation: &Behavior<Animation>)

Register animation with sprite

Source

pub fn pause(&mut self, sprite_id: Uuid, animation: &Behavior<Animation>)

Pause a running animation of the sprite

Source

pub fn resume(&mut self, sprite_id: Uuid, animation: &Behavior<Animation>)

Resume a paused animation of the sprite

Source

pub fn toggle(&mut self, sprite_id: Uuid, animation: &Behavior<Animation>)

Toggle an animation of the sprite

Source

pub fn stop(&mut self, sprite_id: Uuid, animation: &Behavior<Animation>)

Stop a running animation of the sprite

Source

pub fn stop_all(&mut self, sprite_id: Uuid)

Stop all running animations of the sprite

Source

pub fn running(&self) -> usize

Get all the running animations in the scene

Source

pub fn running_for_child(&self, sprite_id: Uuid) -> Option<usize>

Get the number of running animations for a sprite. If sprite does not exist, returns None.

Source

pub fn add_child(&mut self, sprite: Sprite<I>) -> Uuid

Add sprite to scene

Source

pub fn remove_child(&mut self, id: Uuid) -> Option<Sprite<I>>

Remove the child by id from the scene’s children or grandchild will stop all the animations run by this child

Source

pub fn remove_child_when_done(&mut self, id: Uuid)

Remove the child by id from the scene’s children or grandchild once all of its animations have finished. If the child current has no animations, it is removed immediately. Children with paused animations will not be removed until the animations are resumed and completed.

Source

pub fn child(&self, id: Uuid) -> Option<&Sprite<I>>

Find the child by id from the scene’s children or grandchild

Source

pub fn child_mut(&mut self, id: Uuid) -> Option<&mut Sprite<I>>

Find the child by id from this sprite’s children or grandchild, mutability

Source

pub fn children(&self) -> &Vec<Sprite<I>>

Get the list of top-level (non-child) sprites.

Auto Trait Implementations§

§

impl<I> Freeze for Scene<I>

§

impl<I> RefUnwindSafe for Scene<I>
where I: RefUnwindSafe,

§

impl<I> !Send for Scene<I>

§

impl<I> !Sync for Scene<I>

§

impl<I> Unpin for Scene<I>

§

impl<I> UnwindSafe for Scene<I>
where I: RefUnwindSafe,

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>,

Source§

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>,

Source§

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.