How to set specific sprite animation frames to be played by code?

Hello,

I was reading a blog about the sprites animation by Brent which was very helpful. Is there any way to tell the animation what frames to play by code? The code below tells it in the sequenceData to play 1,2,3,4,5,6,7 frames. But I may want only 4,5,6,7 to play. I know I could create different sequenceData fields and use what is needed but I would rather just know how to do this if it is possible. I may want a character to show one set of frames until it is killed or some other action. And then play the frames for the new action.

Thanks,

Warren

local sheetData = { width=512, height=256, numFrames=8, sheetContentWidth=1024, sheetContentHeight=1024 }  
   
local mySheet = graphics.newImageSheet( "runningcat.png", sheetData )  
local sequenceData = {  
{ name = "fastRun", frames={ 1,2,4,5,6,7 }, time=250 }  
}  
local animation = display.newSprite( mySheet, sequenceData )  
animation.x = display.contentWidth/2 --center the sprite horizontally  
animation.y = display.contentHeight/2 --center the sprite vertically  
animation:play()  

[import]uid: 184193 topic_id: 36701 reply_id: 336701[/import]

Hi @warrenwsav,
Ultimately, I think you’re better off setting up the necessary sequences. You might be able to jury-rig some setFrame + onComplete listener to jump back to some other frame, but that is more work and more confusion than it’s worth. Sequences are the way to go.

Brent [import]uid: 200026 topic_id: 36701 reply_id: 145044[/import]

Hi @warrenwsav,
Ultimately, I think you’re better off setting up the necessary sequences. You might be able to jury-rig some setFrame + onComplete listener to jump back to some other frame, but that is more work and more confusion than it’s worth. Sequences are the way to go.

Brent [import]uid: 200026 topic_id: 36701 reply_id: 145044[/import]

Hi @warrenwsav,
Ultimately, I think you’re better off setting up the necessary sequences. You might be able to jury-rig some setFrame + onComplete listener to jump back to some other frame, but that is more work and more confusion than it’s worth. Sequences are the way to go.

Brent [import]uid: 200026 topic_id: 36701 reply_id: 145044[/import]

Hi @warrenwsav,
Ultimately, I think you’re better off setting up the necessary sequences. You might be able to jury-rig some setFrame + onComplete listener to jump back to some other frame, but that is more work and more confusion than it’s worth. Sequences are the way to go.

Brent [import]uid: 200026 topic_id: 36701 reply_id: 145044[/import]