What is the easiest way to change a picture for a couple of second and back to the first one.

I have a sprite of crying baby. What I want is that when the player collide with the baby the crying baby change into baby eating for a couple of second and then back to crying baby. Any Idea how can I accomplish this?

So far I made the crying baby and eating baby in one spritesheet. And then I have 2 sprite.add (blabla, crying) and (blibli, eating)

I called them when there is collision I use
baby:prepare(eating)
baby:play(eating)

When there is no collision I use
baby:prepare(crying)
baby:play(crying)

And I also want to use baby.timeScale = 0.1

So far… It doesn’t work because when there is collision the eating sprite finish in like 1 second while I want it to eat for 3 second that is why I use timeScale = 0.1

And also it doesn’t go back to crying baby after eating…

confused… Any idea how I can fix this? Or any other easier method that I can use? [import]uid: 117857 topic_id: 23551 reply_id: 323551[/import]

I normally try to provide all sample code necessary to demonstrate, but you want to look into timer.performWithDelay. Make the eating animation play endless, then in the timer (after 3000ms), pause the animation and prepare/play the crying one.

like:
ensure looping during sprite.add

baby:prepare(crying)
baby:play(crying)

when collision:
baby:prepare(eating)
baby:play(eating)

timer.performWithDelay(3000, function() baby:pause() baby:prepare(crying) baby:play(crying) end)

you’ll want to watch your states, like when already eating and gets fed again, there you may want to look into timer.cancel(). [import]uid: 21331 topic_id: 23551 reply_id: 94511[/import]