The game I am creating has an enemy spawn every 3 seconds. When I transition from the scene where the enemys are spawning to the main menu there are alot of glitches, like to enemy spawning at the main menu. I think this would be fixed If I canceled my timers in the function scene:exitScene( event ). I’ve read the docs and I am still confused on what to put in for the arguments for timer.cancel().
[lua]
local function spawnEnemy()
local enemy = display.newImage(“enemy.png”)
--(A bunch of physics properties)
timer.performWithDelay(3000, spawnEnemy)
end
function scene:exitScene( event )
timer.cancel(spawnEnemy)
storyboard.removeAll( )
end
[/lua]
Thank you