pub struct Sprite<I: ImageSize> { /* fields omitted */ }
A sprite is a texture with some properties.
pub fn from_texture(texture: Rc<I>) -> Sprite<I> | [src] |
Crate sprite from a texture
pub fn from_texture_rect(texture: Rc<I>, src_rect: SourceRectangle) -> Sprite<I> | [src] |
Create sprite from a rectangle selection of a texture
Whether or not the sprite is visible
Set the sprite's visibility
Get the sprite's anchor point
The value is normalized. Default value is [0.5, 0.5] (the center of texture)
Set the sprite's anchor point
Get the sprite's position
Set the sprite's position
Set the sprite's draw color (tint)
Get the sprite's rotation (in degree)
Set the sprite's rotation (in degree)
Whether or not the sprite is flipped horizontally.
It only flips the texture of the sprite,
and not the texture of the sprite’s children.
Also, flipping the texture doesn’t alter the anchor
.
If you want to flip the anchor
too,
and/or to flip the children too use: sprite.scale.x *= -1;
Whether or not the sprite is flipped vertically.
It only flips the texture of the sprite,
and not the texture of the sprite’s children.
Also, flipping the texture doesn’t alter the anchor
.
If you want to flip the anchor
too,
and/or to flip the children too use: sprite.scale.y *= -1;
Get the sprite's source rectangle
Set the sprite's source rectangle
pub fn get_texture(&self) -> &Rc<I> | [src] |
pub fn set_texture(&mut self, texture: Rc<I>) | [src] |
Add a sprite as the child of this sprite, return the added sprite's id.
Remove the child by id
from this sprite's children or grandchild
Find the child by id
from this sprite's children or grandchild
Find the child by id
from this sprite's children or grandchild, mutability
Get the sprite's children
pub fn draw<B: Graphics<Texture = I>>(&self, t: Matrix2d, b: &mut B) | [src] |
Draw this sprite and its children
Draw this sprite and its children with color
Get the sprite's bounding box
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static