title: LUA - Unable to make the game restart after the timer finishes
body: <p>I have to make a small game for my college work and at the end of the game I would like it so if you click the game over button it restarts it, however every time I have tried to do this it hasn't worked with either errors or just the game restarting and the game over image not being removed.</p>
  
  <p>I know that the current code exits the app when the gameover sign is clicked due to the closeDownApp function (this is the code from before I tried to add the ability to restart) </p>
  
  <p>Any help on how to do it will be greatly appreciated </p>
  
  <pre><code>--Define the variables
      rotateAmt   = 5
      rotateMin   = -90
      rotateMax   = 90
      cannonRotation  = 0
      cannonForce = 1200
      playerPoints    = 0
      targetHit   = false
      timeLeft    = 600
  
  
  --Define the functions
  function closeDownApp(event)
      os.exit ( )
  end
  
  function update( )
      --decrease the time counter
      timeLeft = timeLeft - 1
      scoreDisplay.text = 'Kills: ' .. playerPoints .. '   Time: ' .. timeLeft
      --check if the time has run out
      if (timeLeft &lt;= 0) then
          --display the final score
          scoreDisplay.text = 'Your score was  ' .. playerPoints
          --remove all of the screen objects
          display.remove(cannonBarrel)
          display.remove(target)
          display.remove(upButton)
          display.remove(downButton)
          display.remove(fireButton)
          --display the 'game over' sign
          gameOver = display.newImage('gameover.png', 150, 75)
          gameOver:addEventListener('tap', closeDownApp)
          -- make a group 
      end
  
      --check if the target has been hit
      if (targetHit == true) then
          targetHit = false
          playerPoints = playerPoints + 1
          Hit = display.newImage('Hit.png', target.x, target.y)
          --replace the target with the hit picture
          transition.dissolve(Hit, target, 1000, 0)
          display.remove(bullet)
          --put the target back to a random position
          target.x = math.random(280, 500 )
          target.y = math.random(100, 290 )
      end
  end
  
  function onCollide(event)
      targetHit=true
  end
  
  function fire(event)
      --only fire at the beginning of a touch event
      if (event.phase == 'began') then
          media.playSound('bang.wav')
          bullet = display.newImage('bullet.png')
          --move the image
          bullet.x, bullet.y = cannonBarrel:localToContent(70, 0)
          bullet.rotation = cannonRotation
          --apply physics to the cannonball
          physics.addBody( bullet, { density=2.0, friction=0.2, radius=15 } )
          --determine the appropriate ratio of horizontal to vertical force
          force_x = math.cos(math.rad(cannonRotation)) * cannonForce
          force_y = math.sin(math.rad(cannonRotation)) * cannonForce
          --fire the cannonball
          bullet:applyForce( force_x, force_y, bullet.x, bullet.y )
      end
  end
  
  function moveDown(event)
      --only move the barrel if the touch event started
      if (event.phase == 'began') then
          cannonRotation = cannonRotation + rotateAmt
          if (cannonRotation &gt;= rotateMax) then
              cannonRotation = rotateMax
          end
          cannonBarrel.rotation = cannonRotation
          fireButton.rotation = cannonRotation
      end
  end
  
  function moveUp(event)
      --only move the barrel if the touch event started
      if (event.phase == 'began') then
          cannonRotation = cannonRotation - rotateAmt
          if (cannonRotation &lt;= rotateMin) then
              cannonRotation = rotateMin
          end
          cannonBarrel.rotation = cannonRotation
          fireButton.rotation = cannonRotation
      end
  end
  
  function makeTarget( )
      target = display.newImage('target.png')
      target.x = math.random(280, 450)
      target.y = math.random(100, 290)
      physics.addBody(target,{density=1.0, friction=0.5, bounce=0.05, radius=15})
      target.bodyType = 'static'
      target:addEventListener('collision', onCollide)
  end
  
  function makeInterface( )
      --up button
      upButton = display.newImage('up_button.png')
      upButton:translate(3, 37)
      upButton:addEventListener('touch', moveUp) 
      --down button
      downButton = display.newImage('down_button.png')
      downButton:translate(3, 176)    
      downButton:addEventListener('touch', moveDown)  
      --fire button
      fireButton = display.newImage('fire_button.png')
      fireButton:translate(19, 124)
      fireButton:addEventListener('touch', fire)
      --display cannon parts
      cannonBarrel = display.newImage('cannon_barrel.png')
      cannonBarrel:translate(73, 109)     
      --display score
      scoreDisplay = display.newText( ('Points: ' .. playerPoints), 70, -18, native.systemFont, 20 )
      scoreDisplay:setTextColor( 255,255,255 )
      scoreDisplay:translate(display.contentHeight /2, 30)
  end
  
  --Define control structure
  function init( )
      audio.stop (1)
      display.setStatusBar(display.HiddenStatusBar)
      background = display.newImage('bg.jpg')
      physics = require('physics')
      physics.setDrawMode('normal')
      physics.start( )
      makeInterface( )
      makeTarget( )
      Runtime:addEventListener('enterFrame', update)
      local backgroundMusic = audio.loadStream("theme.mp3")
      local backgroundMusicChannel = audio.play( backgroundMusic,{channel=2, loops=-1, fadein=10 })
      audio.setVolume( 0.5, { channel=backgroundMusicChannel } )
  end
  
  function introScreen( )
      local backgroundMusic1 = audio.loadStream("intro.mp3")
      local backgroundMusicChannel1 = audio.play( backgroundMusic1,{channel=1, loops=1, fadein=10 })
      -- Display the background
      background = display.newImage ("IntroScreen.png")
      -- Display the play button at the top right
      playBtn = display.newImage ("playBtn.png", 350, 10)
      playBtn:addEventListener('tap', init)
  end
  
  --Call the code
  introScreen( )
  </code></pre>