[Problem] at GameOver

HI! I have finished my game, but when I got to the gameover´s screen I have a error…

there is the code of game and then I put the image of the error. Thx for the answers.

local storyboard = require ("storyboard")local scene = storyboard.newScene() local dianas = display.newGroup( ) local totalElementos = display.newGroup( ) local runtime = 0 local velocidad = 10 local tiempoGenerar = 1000 function scene:createScene(event) score = 0 fondo = display.newImageRect("fondoJuego.png", display.contentWidth, display.contentHeight) railIzq = display.newImageRect( "rail.png", 60, display.contentHeight) railDch = display.newImageRect( "rail.png", 60, display.contentHeight) fondo.x = display.contentWidth / 2 fondo.y = display.contentHeight / 2 railIzq.x = 75 railIzq.y = display.contentHeight/2 railDch.x = display.contentWidth -75 railDch.y = display.contentHeight/2 scoreTxt = display.newText( score, display.contentWidth/2, 50, native.systemFont, 40) scoreTxt:setFillColor( 0.9, 0.1, &nbsp;0.1, 1) totalElementos:insert( fondo ) totalElementos:insert( railIzq ) totalElementos:insert( railDch ) totalElementos:insert( scoreTxt ) end function generar( event ) if (tiempoGenerar \> 200) then if (velocidad \< 22) then velocidad = velocidad + 1 end tiempoGenerar = tiempoGenerar - 100 end if (velocidad == 18 and tiempoGenerar == 200) then velocidad = 23 tiempoGenerar = 150 end print(velocidad) print(tiempoGenerar) local posX = math.random( 1 , 2 ) local posIzq = 75 local posDch = display.contentWidth - 75 if posX == 1 then diana = display.newImage( "diana.png" , posIzq , &nbsp;-100) diana:addEventListener( "touch", eliminarDiana ) else diana = display.newImage( "diana.png" , posDch , &nbsp;-100) diana:addEventListener( "touch", eliminarDiana ) end dianas:insert( diana )-- ERRRRRRRRRRRRRRRRROOOOOOOOOOOOOOOOOOOOOORRRRRRR LINE 51 (suguessing) totalElementos:insert( dianas ) dianas:toFront( ) scoreTxt:toFront( ) generarDianas = timer.performWithDelay( tiempoGenerar, generar, 1) end local generarDianas = timer.performWithDelay( 600, generar, 1) function getDeltaTime() local temp = system.getTimer()&nbsp; local dt = (temp- runtime) / (1000/30) &nbsp; runtime = temp &nbsp; return dt end function moverDianas( event ) local dt = getDeltaTime() for i = dianas.numChildren,1,-1 &nbsp;do if(dianas[i].y \> display.contentHeight + 200) then dianas:remove(dianas[i]) &nbsp; &nbsp; &nbsp; &nbsp; storyboard.gotoScene("gameOver", "fade", 600) else dianas[i].y = dianas[i].y + velocidad \* dt end end end Runtime:addEventListener("enterFrame", moverDianas ) function eliminarDiana( event ) if (event.phase == "began") then score = score + 1 scoreTxt.text = score event.target:removeSelf( ) end end function start(event) end function scene:enterScene(event) storyboard.purgeScene("menu") end function scene:exitScene(event) Runtime:removeEventListener("enterFrame", moverDianas) totalElementos:removeSelf( ) totalElementos = nil timer.cancel( generarDianas ) end function scene:destroyScene(event) end scene:addEventListener("createScene", scene) scene:addEventListener("enterScene", scene) scene:addEventListener("exitScene", scene) scene:addEventListener("destroyScene", scene) return scene

Looks like its saying from:

diana = display.newImage( "diana.png" , posDch , &nbsp;-100)

diana is nil, are you sure the image diana.png is in the correct path and that exact spelling? Would be useful to use some type of print statement to see whats happenings before you add these event listeners and inserts

The problem was in this part of code. I did bad the disposes.

wrong code:

function scene:exitScene(event) Runtime:removeEventListener("enterFrame", moverDianas) totalElementos:removeSelf( ) totalElementos = nil timer.cancel( generarDianas ) end

Right code:

function scene:exitScene(event) timer.cancel( generarDianas ) timer.cancel( generarDianas2 ) -- IMPORTANTE, porque si no uso una segunda variable para un timer con la misma funcion,&nbsp; -- al cancelarlo solo cancelamos uno y el otro sigue y no deja continuar la escena Runtime:removeEventListener( "enterFrame", moverDianas ) totalElementos:removeEventListener( "touch", eliminarDiana ) totalElementos:removeSelf( ) totalElementos = nil end

thx for your answer!

Looks like its saying from:

diana = display.newImage( "diana.png" , posDch , &nbsp;-100)

diana is nil, are you sure the image diana.png is in the correct path and that exact spelling? Would be useful to use some type of print statement to see whats happenings before you add these event listeners and inserts

The problem was in this part of code. I did bad the disposes.

wrong code:

function scene:exitScene(event) Runtime:removeEventListener("enterFrame", moverDianas) totalElementos:removeSelf( ) totalElementos = nil timer.cancel( generarDianas ) end

Right code:

function scene:exitScene(event) timer.cancel( generarDianas ) timer.cancel( generarDianas2 ) -- IMPORTANTE, porque si no uso una segunda variable para un timer con la misma funcion,&nbsp; -- al cancelarlo solo cancelamos uno y el otro sigue y no deja continuar la escena Runtime:removeEventListener( "enterFrame", moverDianas ) totalElementos:removeEventListener( "touch", eliminarDiana ) totalElementos:removeSelf( ) totalElementos = nil end

thx for your answer!