Commit 8a478b46 authored by Rahix's avatar Rahix 🦀
Browse files

sprite: Allow passing `Sprite` directly

Allow passing either an ImageHandle or a `Sprite` to Sprite::new().
parent ff31586d
...@@ -5,7 +5,9 @@ pub struct Sprite { ...@@ -5,7 +5,9 @@ pub struct Sprite {
} }
impl Sprite { impl Sprite {
pub fn new(image_handle: resources::ImageHandle) -> Self { pub fn new<S: Into<resources::ImageHandle>>(handle: S) -> Self {
Sprite { image_handle } Sprite {
image_handle: handle.into(),
}
} }
} }
...@@ -21,6 +21,6 @@ pub fn create_player( ...@@ -21,6 +21,6 @@ pub fn create_player(
components::Position::new(spawn.x, spawn.y), components::Position::new(spawn.x, spawn.y),
components::Movable::new(), components::Movable::new(),
colliders::Collider::new_player(50.0), colliders::Collider::new_player(50.0),
components::Sprite::new(sprites::Sprite::Player.into()), components::Sprite::new(sprites::Sprite::Player),
)) ))
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment