I have a pause button that works well until after I unpause the game. I have a timer that is supposed to be created again (I can’t pause them as a trial user), but it isn’t doing that.
Error to prove it’s not being created:
Windows simulator build date: Dec 9 2011 @ 14:01:29
Copyright (C) 2009-2011 A n s c a , I n c .
Version: 2.0.0
Build: 2011.704
Paused
Unpaused
Paused
Runtime error
?:0: attempt to index a nil value
stack traceback:
[C]: ?
?: in function 'cancel'
...le\documents\my code\corona sdk\makin' bank\game.lua:109: in function
<...le code sdk bank><br> ?: in function <?:21 <br>Memory Usage: 0.132326171875 MB<br>Texture Usage: 8.912896<br>
Code:
[lua] local function pauseGame()
isPaused = not isPaused
if isPaused then
buttonPause:prepare(“pauset”)
buttonPause:play(“pauset”)
physics.pause()
buttonLeft:removeEventListener(“touch”, moveLeft)
buttonRight:removeEventListener(“touch”, moveRight)
Runtime:removeEventListener(“enterFrame”, moveCharacter)
Runtime:removeEventListener(“touch”, stopCharacter)
timer.cancel(createCoinsTimer) – Change to Pause
else
buttonPause:prepare(“pauseu”)
buttonPause:play(“pauseu”)
physics.start()
buttonLeft:addEventListener(“touch”, moveLeft)
buttonRight:addEventListener(“touch”, moveRight)
Runtime:addEventListener(“enterFrame”, moveCharacter)
Runtime:addEventListener(“touch”, stopCharacter)
createCoinsTimer = timer.performWithDelay(500, createCoins, 0) – Change to Resume
end
end[/lua]
I have another question, and I might as well get it answered here: Do I need to remove local objects/timers in my exitScene and destroyScene functions, or are they automatically removed? I’m confused on what is removed automatically and what isn’t. Also, if I have a global object that is in the local group, is that removed automatically? [import]uid: 103624 topic_id: 19300 reply_id: 319300[/import] </…le>
[import]uid: 52491 topic_id: 19300 reply_id: 74495[/import]