Corona SDK: Animation takes a long time to play after "prepare" step

Posted by Michael Taufen on Game Development See other posts from Game Development or by Michael Taufen
Published on 2012-06-18T16:09:37Z Indexed on 2012/06/18 21:24 UTC
Read the original article Hit count: 373

Filed under:
|
|

First off, I'm using the current publicly available build, version 2011.704

I'm building a platformer, and have a character that runs along and jumps when the screen is tapped. While jumping, the animation code has him assume a svelte jumping pose, and upon the detection of a collision with the ground, he returns to running. All of this happens.

The problem is that there is this strange gap of time, about 1/2 a second by the feel of it, where my character sits on the first frame of the run animation after landing, before it actually starts playing. This leads me to believe that the problem is somewhere between the "prepare" step of loading up a sprite set's animation sequence and the "play" step. Thanks in advance for any help :).

My code for when my character lands is as follows:

local function collisionHandler ( event )
    if (event.object1.myName == "character") and (event.object2.type == "terrain") then
        inAir = false
        characterInstance:prepare( "run" ) -- TODO: time between prepare and play is curiously long...
        characterInstance:play()
    end
end

© Game Development or respective owner

Related posts about iphone

Related posts about animation