Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Engel Simulator 2020
Engel Simulator 2020
Commits
8a478b46
Commit
8a478b46
authored
Dec 26, 2020
by
Rahix
🦀
Browse files
sprite: Allow passing `Sprite` directly
Allow passing either an ImageHandle or a `Sprite` to Sprite::new().
parent
ff31586d
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/components/sprite.rs
View file @
8a478b46
...
@@ -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
(),
}
}
}
}
}
src/entities/player.rs
View file @
8a478b46
...
@@ -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
),
))
))
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment