OK, I have a problem and not sure what is causing it.
I have a game which has a scene called Gamplay.lua. In this game you can pause the action which opens a overlay scene. On this overlay I have two buttons. One button allows the user to restart the level.
I had an issue about how to restart the level so I came up with this idea: -
In gameplay and the user selects Pause: -
storyboard.showOverlay( “pauseOverlay”, options ) is called with the level number as a parameter.
User selects restart.
storyboard.gotoScene( “RestartLevel”, options ) is called. Now, in the CreateScene event of Restart level I call: -
local prior_scene = storyboard.getPrevious()
storyboard.purgeScene( prior_scene )
My understanding is that this will purge both the Gameplay.lua module (??) as the pause screen was shown as an overlay.
The RestartLevel then calls: -
storyboard.gotoScene( “gameplay”, options )
with the level id as a parameter.
The Problem
This works for on iteration. I start playing, pause the game, click restart and the level resets. I can then play the level if I want. If I pause it again (on the second iteration) and click restart I get the error: -
Error Table Expected in the PauseOverlay file. Complaining about the function insert which can only be the Group:Insert function which is not called when Restart is pressed.
Has anyone had this problem before? Is there a better way of restarting a level? I do not want to try and reset all objects. It is much quicker just to purge the entire thing and reload. Any help you can offer would be great!