Play sprite animtion while touching

Hi!

Some code

function handleEnterFrame() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;hero1.rotation = 0 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(moveToLeft ==&nbsp; true) then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;hero1.x = hero1.x -7.5 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;hero2.x = hero2.x -7.5 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;heroAnim:setSequence( "left" ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;heroAnim.x = heroAnim.x -7.5; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;heroAnim:play(); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;function Move(event) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if ( event.phase == "began" ) then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(event.x \<= \_W) then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;moveToLeft = true &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;elseif ( event.phase == "ended") then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;moveToLeft = false &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;moveToRight = false &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;heroAnim:setSequence( "stay" ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;heroAnim:play(); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp;&nbsp; Runtime:addEventListener( "enterFrame", handleEnterFrame ) &nbsp;&nbsp; &nbsp;Runtime:addEventListener( "touch", Move )

When i touch screen my sprite move to left side and anims stop play :frowning:

I know why: heroAnim:play(); start all the time. How to repair this code. There’s on event on focus touching the screen?

Thanks in advice

Just a note. The ‘ended’ event phase for ‘touch’ does not always get triggered, especially when it is a ‘fast scroll touch’ (someone scrolling x/y direction). I usually put a timer to continue animation if there isn’t any ‘ended’ received after 100ms.

yea but timer want to start in every frame, result was the some

any ideas?

Just a note. The ‘ended’ event phase for ‘touch’ does not always get triggered, especially when it is a ‘fast scroll touch’ (someone scrolling x/y direction). I usually put a timer to continue animation if there isn’t any ‘ended’ received after 100ms.

yea but timer want to start in every frame, result was the some

any ideas?