how to run animation when my character move

so i am new to composer api so i do not knw where to update the animation of my player some help plz?

local sheetOptions =

{

    width = 75,

    height = 90,

    numFrames = 10

}

local sheet_charwalk = graphics.newImageSheet( “images/character/male/male-walk.png”, sheetOptions )

local sequence_char={

{

name=“walk”,

start= 1,

count =10,

time = 800,

loopCount = 0,

        loopDirection = “forward”

},

{

name=“idle”,

frames = { 1 },

time = 800,

loopCount = 0,

        loopDirection = “forward”

}

}

local charwalk = display.newSprite( sheet_charwalk, sequence_char ) 

the question now is where do i put the charwalk:play() and how to change idle to walk when i move my char with dpad

anyone knows?

Hi @pehzeming,

The following guide outlines all of the sprite methods and properties. When you need to change a sequence (“idle” to “walk” for example), use :setSequence() and then sprite:play() to being animating on that sequence.

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

Best regards,

Brent

yea i knw that but which part of the composer do i put it? show() or create()?

Hi @pehzeming,

I’m not sure that I understand your question. Do you want to control the sprite animation (changing sequences) by using a function? If so, you should put that function outside of all Composer “scene:” functions, so it resides in the proper scope and can be recognized from all places within the scene module that you might need to call it.

Brent

anyone knows?

Hi @pehzeming,

The following guide outlines all of the sprite methods and properties. When you need to change a sequence (“idle” to “walk” for example), use :setSequence() and then sprite:play() to being animating on that sequence.

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

Best regards,

Brent

yea i knw that but which part of the composer do i put it? show() or create()?

Hi @pehzeming,

I’m not sure that I understand your question. Do you want to control the sprite animation (changing sequences) by using a function? If so, you should put that function outside of all Composer “scene:” functions, so it resides in the proper scope and can be recognized from all places within the scene module that you might need to call it.

Brent