pub struct Sprite { /* private fields */ }
Expand description

Representation of a sprite.

Implementations

Create a new Sprite. The path is relative to the current directory while running.

Don’t forget to call draw() after this.

let s = Sprite::new("duck.png", 500, 400).unwrap();

Draws the sprite to the window. This should only be called inside your main event loop.

s.draw(ctx);

Translate the sprite, in the form of (delta x, delta y)

s.translate((5, 10));

Set the angle of the sprite, in degrees of clockwise rotation.

s.set_angle(45.0);

Get the angle of the sprite, in degrees of clockwise rotation.

let angle = s.angle();

Get the x and y coordinates of the center of the sprite, in the form of (x, y).

let (x, y) = s.position();

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.