Hello everyone,
When I press back key the Runtime:enterFrame should stop and on pressing the back key again after 1 sec the Runtime:enterFrame should start, but in that one sec time if I keep on tapping back key again and again something weird starts happening the object start to move fast and fast, the below is my code
coal=0 local ball=display.newCircle( 100, 100, 50 ) function move( ) ball.x=ball.x+1 end Runtime:addEventListener("enterFrame",move) local function onKeyEvent( event ) if ( event.keyName == "back" ) then if ( system.getInfo("platform") == "android" ) then if event.phase=="up" then coal=coal+1 if coal%2~=0 then Runtime:removeEventListener("enterFrame",move) else timer.performWithDelay(1000,function() Runtime:addEventListener( "enterFrame", move ) end,1) end end return true end end end Runtime:addEventListener( "key", onKeyEvent )
Help from everyone is welcome.
Thanks and Regards,
Swanand Thakur.
