[2D][SpriteSheet] Change sprite sheets #5289
Unanswered
The-DevBlog
asked this question in
Q&A
Replies: 1 comment
-
A solution would be to have a resource that stores the player handles. It may look like this, for example: pub struct PlayerHandles {
pub idle_left: Handle<TextureAtlas>,
pub idle_right: Handle<TextureAtlas>,
pub idle_up: Handle<TextureAtlas>,
pub idle_down: Handle<TextureAtlas>,
} When the To have the 4 different handles, you'll need to add them to the assets separately, so after the Hope it's clear and it helps! Let us know if not. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have separate spritesheets I want to play when the player moves up, down, left & right. I figured I could 'load' all the assets on setup, then just switch which one im actively using in my movement system. The problem is, I cant seem to figure out a good way to modify the current Image Handle.
Here is some sample code of the logic I am currently using.
This is the movement system. When I press 'A', I want the left facing spritesheet to be used, and similarly with the 'W', 'D', & 'S' keys. This is currently the only way I can seem to get it to work. The issue with this is that I am always creating a new 'Handle
' instead of modifying the existing one. I've tried to modify the existing one by passing in '&Handle
' in the query, but that does not work.
Beta Was this translation helpful? Give feedback.
All reactions