I am creating an app with start.lua , game.lua and restart.lua scenes . When I click start I go into the game , play the game smoothly . When I die I go to the restart.lua scene . I click restart and go back to game.lua . I can do this a number of times until a certain point where I get this error :
ERROR: Runtime error ?:0: attempt to index field 'contentBounds' (a nil value) stack traceback: ?: in function '\_saveSceneAndHide' ?: in function 'gotoScene' restart.lua:26: in function '?'
I did not add a _saveSceneAndHide function to any of my scenes , Can someone help me with this problem ?
restart.lua:
-- requires local composer = require( "composer" ) local scene = composer.newScene() -- background function scene:create(event) local screenGroup = self.view local randomImage = math.random(1,33) local background = display.newImageRect("images/background"..randomImage..".jpg",display.contentWidth,display.contentHeight) background.x = display.contentCenterX background.y = display.contentCenterY screenGroup:insert(background) local restart = display.newText( "Touch Screen to Play Again", display.contentCenterX, display.contentCenterY, native.systemFont, 25 ) screenGroup:insert(restart) end local function touchScreen( event ) if event.phase == "began" then composer.gotoScene("game", "fade", 400) --line 26 where is error is happening end end function scene:show(event) composer.removeScene( "game" ) Runtime:addEventListener("touch", touchScreen) end function scene:hide(event) display.remove(currentTimeText) Runtime:removeEventListener("touch", touchScreen) end function scene:destroy(event) end scene:addEventListener("create", scene) scene:addEventListener("show", scene) scene:addEventListener("hide", scene) scene:addEventListener("destroy", scene) return scene