That doesn’t work
function scene:destroyScene(event) local number = 0 timer.cancel( fnCounter\_timer ) end
That’s what I put
That doesn’t work
function scene:destroyScene(event) local number = 0 timer.cancel( fnCounter\_timer ) end
That’s what I put
Ok so just do this.
local score = 0 local scoreTxt = display.newText( "0", 0, 0, native.systemFontBold, 40 ) scoreTxt.x = display.contentCenterX scoreTxt.y = 20 sceneGroup:insert(scoreTxt) local function updateScore() score = score + 1 scoreTxt.text = string.format("%d", score ) end local scoreTimer = timer.performWithDelay(1000, updateScore, -1)
So i’m using a string here that gets updated every second… And that shows the score… So when you are going to your next scene you do this.
local function gotoNext() composer.gotoScene( "bob" ) display.remove(scoreTxt) timer.cancel( scoreTimer ) end
Now when you start the game again then the score will be 0 and then timer will start like normal.
MAKE SURE you are in scope! I don’t want to here that this isn’t working because i use this in every game i make. Not trying to sound rude or police you but this is the simplest way i could give you to do it.
–SonicX278
I would cancel the timer BEFORE storyboard.gotoScene and don’t forget to nil the reference to it.
local function onCollision( event ) if event.phase =="began" then timer.cancel( fnCounter\_timer ) fnCounter\_timer = nil storyboard.gotoScene("restart", "fade", 400) end end
Ahh yes! Sorry I missed that part.
–SonicX278
Runtime error
?:0: attempt to index a nil value
stack traceback:
?: in function ‘cancel’
C:\Users\brandon\Documents\Corona Projects\MineDodge\game.lua:146: in fu
nction <C:\Users\brandon\Documents\Corona Projects\MineDodge\game.lua:144>
?: in function <?:221>
I am getting this error
I don’t have skype . This is line 146
timer.cancel( fnCounter\_timer )
Can you just send me the file over email? I’m free right now and can just fix this…
Email – REMOVED
I’m just tired of saying the same thing over and over without getting anywhere.
–SonicX278
I did
Ok ill email you from here.
–SonicX278