sprite problem

I have a  6 frames sprites 1,2,3 frame is run and the 4,5,6 is jump can i make the sprite run the 4,5,6 frame when I press a button and run 1,2,3 frame when  release the button ?

Yes. You need to define 2 sequences (1,2,3) and (4,5,6) and switch the sequence when interacting with the button.

See for example http://coronalabs.com/blog/2012/10/02/animated-sprites-and-methods/

`

\_W = display.contentWidth \_H = display.contentHeight local button = display.newRect(110,110,40,40) local sheetData = { width=157, height=113, numFrames=6, sheetContentWidth=942, sheetContentHeight=113 } sheet1 = graphics.newImageSheet( "monster1.png", sheetData) local sequenceData = { { name="normalRun", start=1, count=3, time=400}, { name="fastRun", frames={ 4,5,6 }, time=400 } } monster = display.newSprite( sheet1, sequenceData ) monster.xScale , monster.yScale = .7 ,.65 monster:play() monster.anchorX ,monster.anchorY = 0,0 monster.y = \_H/2+50 monster.x = 40 local function mySpriteListener( event ) if ( event.phase == "ended" ) then local thisSprite = event.target --"event.target" references the sprite thisSprite:setSequence( "fastRun" ) --switch to "fastRun" sequence thisSprite:play() --play the new sequence; it won't play automatically! end end monster:addEventListener( "sprites", mySpriteListener )

I follow the example but i don’t know how to change the frame am i need to add a touch listener 

Yes. You need to define 2 sequences (1,2,3) and (4,5,6) and switch the sequence when interacting with the button.

See for example http://coronalabs.com/blog/2012/10/02/animated-sprites-and-methods/

`

\_W = display.contentWidth \_H = display.contentHeight local button = display.newRect(110,110,40,40) local sheetData = { width=157, height=113, numFrames=6, sheetContentWidth=942, sheetContentHeight=113 } sheet1 = graphics.newImageSheet( "monster1.png", sheetData) local sequenceData = { { name="normalRun", start=1, count=3, time=400}, { name="fastRun", frames={ 4,5,6 }, time=400 } } monster = display.newSprite( sheet1, sequenceData ) monster.xScale , monster.yScale = .7 ,.65 monster:play() monster.anchorX ,monster.anchorY = 0,0 monster.y = \_H/2+50 monster.x = 40 local function mySpriteListener( event ) if ( event.phase == "ended" ) then local thisSprite = event.target --"event.target" references the sprite thisSprite:setSequence( "fastRun" ) --switch to "fastRun" sequence thisSprite:play() --play the new sequence; it won't play automatically! end end monster:addEventListener( "sprites", mySpriteListener )

I follow the example but i don’t know how to change the frame am i need to add a touch listener