Hey, i’m completely new to Corona. I’m using Texture Packer to create sprite sets (but I believe that this is neither here nor there). I basically have some code that, would when the user presses a button, will run one animation. I want it to be able to run one animation followed by another one, but I am not able to get this to work. It basically will only run the second animation (or at least that is all I see).
local spriteSet = sprite.newSpriteSet(characterSheet, 1, 23)
sprite.add( spriteSet, "left\_turn", 1, 3, 1000, 0)
sprite.add( spriteSet, "right\_turn", 8, 1, 1000, 0)
sprite.add( spriteSet, "left\_move", 10, 7, 1000, 0)
sprite.add( spriteSet, "right\_move", 17, 7, 1000, 0)
sprite.add( spriteSet, "prone", 4, 1, 1, 0)
-- move code...
function leftArrow:touch(event)
motionx = -speed
motiony = 0
if dude.direction == "right" then -- "direction" is custom field, dude is facing right
dude:prepare("left\_turn")
dude:play() -- i'm not seeing this
dude:prepare("left\_move")
dude:play()
end
end
leftArrow:addEventListener("touch",leftArrow)
Any help at all would be great. Ta [import]uid: 125022 topic_id: 29739 reply_id: 329739[/import]
You set things up the right way, then your various functions wait to be notified by various methods (timer, event listeners, transition onCompletes etc) that something happened, execute some code in response to the notification (quickly, not to slow down the action), then return and the wait continues. A lot of things (sprites animating, things moving during transitions, physics actions) happen by themselves during those “wait” times, without your code having to perform those things. Sometimes you have to do special animations in the space inbetween the video “frames” (that happen 30 or 60 times a second) - look at the Runtime “enterFrame” event listener documentation.