Not sure if I was doing some wrong but I found it kept resetting the frame as well as playing the animation.
However, I got it to work with the following using the latest sprite logic
[lua]local oldStyleSpriteSheetData = require(“mysprite”).getSpriteSheetData()
myspriteposition = “middle”
local options =
{
spriteSheetFrames = oldStyleSpriteSheetData.frames
}
local imageSheet = graphics.newImageSheet( “mysprite.png”, options )
local sequenceData = {
{ name=“movement”, start=1, count=32, time=750, loopCount=1 }
}
local mysprite = display.newSprite( imageSheet, sequenceData )
mysprite.x = 200
mysprite.y = 200
local currentFrame
– The user has clicked on the screen
function screenTouched (event)
if event.phase == “began” then
if not(myspriteposition == “background”) then
mysprite:setSequence( “movement” )
mysprite:play()
myspriteposition = “background”
end
elseif event.phase == “ended” then
if not(myspriteposiiton== “middle”) then
currentFrame = mysprite.frame
tmr = timer.performWithDelay(15, reverseAnim, 1)
myspriteposition = “middle”
end
end
return true
end
function reverseAnim()
if currentFrame > 1 then
currentFrame = currentFrame -1
mysprite:setFrame(currentFrame)
tmr = timer.performWithDelay(15, reverseAnim, 1)
else
mysprite:setFrame(1)
myspritet:pause()
end
end
Runtime:addEventListener( “touch”, screenTouched )[/lua]
Note: I am using TexturePacker and the old style technique to pull the sheet in.
Thanks Dan for pointing me in the right direction [import]uid: 103970 topic_id: 24115 reply_id: 98050[/import]