What to do with 2 spritesheets

I have two sprite sheets Walking and Idle, but I can only set them in 2 separate sprites, I want to switch their animations in the player state, how do I need to use the 2 sprites

Or how to merge them, since they come from 2 different sprite sheets

You could try to merge the to sprite sheets into one with some sort of external image editing/art software.

If you want to use 2 spritesheets, it’s a little more complicated because both tilesources will have to be used in some way or shape before building the program, otherwise one won’t be compiled.
One simple way to do this is create another sprite within the same object and assign the tilesource and switch between using the sprites by disabling and reenabling them with messages before calling sprite.flipbook to set the animation.

If the method above gives you trouble, you could disable the second sprite and set the first sprite’s image to the seconds with this:

self.idlesheet = go.get("#sprite", "image") -- first spritesheet, idle animations
self.runsheet = go.get("#sprite2", "image") -- second spritesheet, running animations
msg.post("#sprite2", "disable") -- disable the second sprite

-- now when we want to switch the sheet to idles
go.set("#sprite", "image", self.idlesheet)
sprite.play_flipbook("#sprite", facing.."_idle")

-- or if you want to set to the running anims 
go.set("sprite", "image", self.runsheet)
sprite.play_flipbook("#sprite", facing)

(note: #sprite and #sprite2 are arbitrary; they represent the IDs of the sprite’s you’ll be using

If you have to use this option, I recommend making a function for it. And try to call “go.set” only when you need to change the image, not each time you have to change the animation

4 Likes

Thank you for your advice and approach!

2 Likes