After running the adb logcat again, it prints the following:
remove previous scene (before my create scene function)
create scene 5
will enter scene 5
enter scene 5
Then I push the back button and it prints the following:
back button code here
exit scene 5 (where my code is that removes listeners, etc.)
destroy scene 5
remove previous scene (before my create scene function in the menu screen)
create scene menu
will enter scene menu
enter scene menu
Then I try to go back into the same scene 5 and this prints (the same thing happens with other scenes with their respective print statements):
create scene 5
will enter scene 5
enter scene 5
Runtime error
?:0: attempt to call method ‘insert’ (a nil value)
stack traceback:
?: in function ‘_listener’
?: in function (?:141)
So it looks like my back button code is being called before my scene exits. In my back button code, there is the command storyboard.gotoScene( “scene_home” ) but in my scene 5 exit scene function, I am removing all of the listeners and such. Perhaps it is not able to remove the listeners before going to the home scene?