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

A sprite is a texture with some properties.

Implementations

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] (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 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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.