Add ability to set a Sprite's position

This commit is contained in:
Yash Karandikar 2022-05-11 13:34:34 -05:00
parent aae911f81b
commit ad20a2771d

View file

@ -272,6 +272,17 @@ impl Sprite {
self.rect.set_y(new_y);
}
/// Reposition the center of the sprite in the form of (x, y)
///
/// ```
/// # use cat_box::*;
/// # let mut s = Sprite::new("duck.png", 500, 400).unwrap();
/// s.set_position((5, 10));
/// ```
pub fn set_position(&mut self, position: (i32, i32)) {
self.rect.center_on(position);
}
/// Set the angle of the sprite, in degrees of clockwise rotation.
///
/// ```