Problem with sprite sheet - "bounce" phase

I have one  problem that happens sometimes and pretty annoys me. I have sprite sheet of doors which I create like this:

    

    rightDoorSheet=graphics.newImageSheet("images/doors\_sprite.png",{width=256,height=256,numFrames=16});     rightDoorData=display.newSprite(rightDoorSheet,{name="dooropen",frames={1,2,3,4,5,6,7,8,9,10,11,12,13,13},time=500,loopCount=1,loopDirection="bounce"});     rightDoorData.xScale=0.78;     rightDoorData.yScale=0.78;     rightDoorData.x=0;     rightDoorData.y=0;     rightDoorData:addEventListener("sprite",spriteListenerRight);     rightDoorData:setSequence("dooropen");  

    

And I have event listener function spriteListenerRight():

function spriteListenerRight(event)     if(event.phase=="began")then             animatePerson();  -animating person behind these doors     end     if(event.phase=="bounce")then   --when doors are opened start animation of character         event.target:pause();         doSomething();         rightDoorTimer=timer.performWithDelay(1300,function() event.target:play(); end);  -- after time passes close the door     end          if(event.phase=="ended")then         print("phase ended");     end end  

My idea is to open doors every 5 seconds(for example), when doors are in “bounce” phase it should be a little pause(doors are fully open), and after rightDoorTimer expires continue animation(close the door).

Everything works well but sometimes my animation doesn’t go into “bounce” phase(skips some frames) which causes my doors to open and close quickly(without this necessary pause).

Is it something wrong in my code?  

Hi @Kolovrat,

For better “control” of the animations, I would suggest that you just create two different sequences for your doors, i.e. “opening” and “closing”, and then run them at the appropriate times, instead of pausing a “bounce” sequence.

Best regards,

Brent

Hi Brent,

thank you very much for reply! I’ll definitively try that way. I ll post here if it works.

Regards!

Hi @Kolovrat,

For better “control” of the animations, I would suggest that you just create two different sequences for your doors, i.e. “opening” and “closing”, and then run them at the appropriate times, instead of pausing a “bounce” sequence.

Best regards,

Brent

Hi Brent,

thank you very much for reply! I’ll definitively try that way. I ll post here if it works.

Regards!