pub struct Sprite { /* private fields */ }Expand description
Representation of a sprite.
Implementations
sourceimpl Sprite
impl Sprite
sourcepub fn new<P: AsRef<Path>>(path: P, x: i32, y: i32) -> Result<Self>
pub fn new<P: AsRef<Path>>(path: P, x: i32, y: i32) -> Result<Self>
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();sourcepub fn draw(&mut self, ctx: &mut Context) -> Result<()>
pub fn draw(&mut self, ctx: &mut Context) -> Result<()>
Draws the sprite to the window. This should only be called inside your main event loop.
s.draw(ctx);sourcepub fn translate(&mut self, position: (i32, i32))
pub fn translate(&mut self, position: (i32, i32))
Translate the sprite, in the form of (delta x, delta y)
s.translate((5, 10));sourcepub fn set_angle(&mut self, angle: f64)
pub fn set_angle(&mut self, angle: f64)
Set the angle of the sprite, in degrees of clockwise rotation.
s.set_angle(45.0);Auto Trait Implementations
impl RefUnwindSafe for Sprite
impl !Send for Sprite
impl !Sync for Sprite
impl Unpin for Sprite
impl UnwindSafe for Sprite
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more