Struct sprite::Sprite [] [src]

pub struct Sprite<I: ImageSize> { /* fields omitted */ }

A sprite is a texture with some properties.

Methods

impl<I: ImageSize> Sprite<I>
[src]

Crate sprite from a texture

Create sprite from a rectangle selection of a texture

Get the sprite's id

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

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 color.s

Get the sprite's rotation (in degree)

Set the sprite's rotation (in degree)

Get the sprite's scale

Set the sprite's scale

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;

Flip the sprite

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;

Flip the sprite

Get the sprite's opacity

Set the sprite's opacity

Get the sprite's source rectangle

Set the sprite's source rectangle

Get the sprite's texture

Set the sprite's texture

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

Draw this sprite and its children

Draw this sprite and its children with color

Get the sprite's bounding box