lua - Timer called twice in scene Corona SDK -


i have timer in code spawns objects every 1 seconds. when object collides "deathobj" scene changes scene2 scene1. when scene1 return scene2 timer called twice, if retry called 4 times etc... how can call timer once?

function scene:show( event )  local scenegroup = self.view local phase = event.phase  if ( phase == "will" )      elseif ( phase == "did" )         local function spawn()             --things spawn object         end      end       local function deathobjcollision(self, event)         if (event.phase == "began" )         composer.gotoscene("scene1")         end     end      deathobj = display.newrect(300,1900,1600,100)     physics.addbody(deathobj, "static", {density=1.0, friction=0.5, bounce=0.3})     deathobj.collision = deathobjcollision     deathobj:addeventlistener( "collision", deathobj )       spawntimer = timer.performwithdelay(1000, spawn, -1)      end end    

try pause or cancel timer when change scene 2 scene 1.


Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -