Struct sprite::Scene
[−]
[src]
pub struct Scene<I: ImageSize> { // some fields omitted }
A scene is used to manage sprite's life and run animation with sprite
Methods
impl<I: ImageSize> Scene<I>
[src]
fn new() -> Scene<I>
Create a new scene
fn event<E>(&mut self, e: &E) where E: GenericEvent
Update animation's state
fn draw<B: Graphics<Texture=I>>(&self, t: Matrix2d, b: &mut B)
Render this scene
fn draw_tinted<B: Graphics<Texture=I>>(&self, t: Matrix2d, b: &mut B, c: [f32; 3])
Render this scene with tint
fn run(&mut self, sprite_id: Uuid, animation: &Behavior<Animation>)
Register animation with sprite
fn pause(&mut self, sprite_id: Uuid, animation: &Behavior<Animation>)
Pause a running animation of the sprite
fn resume(&mut self, sprite_id: Uuid, animation: &Behavior<Animation>)
Resume a paused animation of the sprite
fn toggle(&mut self, sprite_id: Uuid, animation: &Behavior<Animation>)
Toggle an animation of the sprite
fn stop(&mut self, sprite_id: Uuid, animation: &Behavior<Animation>)
Stop a running animation of the sprite
fn stop_all(&mut self, sprite_id: Uuid)
Stop all running animations of the sprite
fn running(&self) -> usize
Get all the running animations in the scene
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.
fn add_child(&mut self, sprite: Sprite<I>) -> Uuid
Add sprite to scene
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
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.
fn child(&self, id: Uuid) -> Option<&Sprite<I>>
Find the child by id
from the scene's children or grandchild
fn child_mut(&mut self, id: Uuid) -> Option<&mut Sprite<I>>
Find the child by id
from this sprite's children or grandchild, mutability
fn children(&self) -> &Vec<Sprite<I>>
Get the list of top-level (non-child) sprites.