-
Hi, What is the best practice for changing the sprite on an entity? For example, if I want to change the material of an entity created with a SpriteBundle to a different image when it is clicked. Thanks, |
Beta Was this translation helpful? Give feedback.
Answered by
DJMcNab
Sep 30, 2021
Replies: 1 comment
-
The easiest way would be to change it's E.g. fn my_change_system(sprites: Res<MySprites>, query: Query<&mut Handle<ColorMaterial>, With<MyEntity>>) {
let mut handle = query.single_mut();
*handle = sprites.surprised.clone();
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
gmoller
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The easiest way would be to change it's
Handle<ColorMaterial>
component to be to a different sprite handle. You would generally store your sprite handles in a resource.E.g.