question about image sheet and sequence data

I have an image sheet with 16 total images on it. 8 of those images are for a walk animation and the other 8 are for an attack animation.

I have the basic code as follows to introduce the image sheet

 BlairSheetOptions = { width = 142, height = 190, numFrames = 16} Blair\_Sheet = graphics.newImageSheet( "Images/Blair Char Sheet1.png", BlairSheetOptions ) Blair\_Sequence\_Data = { {name = "walk", sheet = Blair\_Sheet, frames = {1,3,5,7,9,11,13,15,}, time = 1000, loopcount = 0, loopDirection = "forward"}, {name = "attack", sheet = Blair\_Sheet, frames = {2,4,6,8,10,12,14,16,}, time = 1000, loopcount = 0, loopDirection = "forward"}, }

following the API I have read that in order for me to switch between the walk animation and attack animation, I must call object:setSequence(“name”).

so for my code I call self:setSequence(“attack”) when the character is attacking and self:setSequence(“walk”) when they are to be moving.

I have noticed though, “walk” seems to be the default animation because it is the first sequence. if I were to just call self:play() without declaring a sequence, it defaults to “walk”

and when I call self:setSequence(“attack”) everything seems to work fine and the animation sequence then switches over.

The issue is when the character stops attacking and I need them to move again… I call self:setSequence(“walk”), but nothing seems to happen, the animation will stop on a single frame and basically end.

Is there an issue with setting a sequence to the first of the table? or am I going about it all wrong?

Hey Ethan,

as far as I can see, the way you are setting things is correct.

I’m not quite sure, what exactly is going wrong. When you set the sequence to “walk” after the attack, does the animation switches to the first frame of the walk sequence?

Here are two sites concerning the topic:

https://coronalabs.com/blog/2013/05/14/sprites-and-image-sheets-for-beginners/

https://docs.coronalabs.com/guide/media/spriteAnimation/index.html

to be a bit more clear,

using the code above, if I were to just call

self:play()

and run the game I would see the character going through the “walk” cycle.

if I simply change the code and add one line before play

self:setSequence(“walk”)

self:play()

and then run the game, the animation no longer runs, it is stuck on the first frame.

the API reference makes sure to mention that you are supposed to call the setSequence before playing the animation, but it seems to just freeze the character on frame 1

Hey Ethan,

as far as I can see, the way you are setting things is correct.

I’m not quite sure, what exactly is going wrong. When you set the sequence to “walk” after the attack, does the animation switches to the first frame of the walk sequence?

Here are two sites concerning the topic:

https://coronalabs.com/blog/2013/05/14/sprites-and-image-sheets-for-beginners/

https://docs.coronalabs.com/guide/media/spriteAnimation/index.html

to be a bit more clear,

using the code above, if I were to just call

self:play()

and run the game I would see the character going through the “walk” cycle.

if I simply change the code and add one line before play

self:setSequence(“walk”)

self:play()

and then run the game, the animation no longer runs, it is stuck on the first frame.

the API reference makes sure to mention that you are supposed to call the setSequence before playing the animation, but it seems to just freeze the character on frame 1