show and hide overlay (pause menu)

so I am working on a pause menu and I have read that the scene under the overlay is still active unless coded otherwise by building in an “if paused then…”

I have also realized that even though the original scene is still active, you cannot access any variables on the original scene.

this poses 2 problems for me.

On the pause screen I have the option to quit the level, so I would need to use composer.removeScene for the original scene, but I need to put in a specific scene name. right now it looks like this composer.removeScene(“Scripts.cave”) and since I am using a universal pause menu for all levels, that currently only works on the one level “Scripts.cave”

composer.removeScene("Scripts.cave")

does anyone have a tip on how to create a variable I can plug in that would read what scene im on and be able to removeScene. I would like it to be something like this 

composer.removeScene(currentScene)

Im not sure how I would get the overlay to know what scene it is covering.

Second question would fall in line with the first with the idea of the overlay needing to know/access the original scene.

On the pause menu I also have a “resume” button, so I would need the resume button to be able to change the “if paused then…” that would be on the original scene, in order turn paused to False and allow play to resume.

Thanks for any help

You can access variables in any scene.  There are several ways that come to mind:

  1. Pass a reference to the current scene to the overlay via params.

  2. In the overlay, request a reference to the current scene and then access it.

https://docs.coronalabs.com/daily/api/library/composer/getSceneName.html

https://docs.coronalabs.com/daily/api/library/composer/getScene.html

local currScene = composer.getSceneName( "current" ) -- returns current scene, not overlay composer.removeScene( currScene )
  1. Use the composer variable functions.

https://docs.coronalabs.com/daily/api/library/composer/getVariable.html

https://docs.coronalabs.com/daily/api/library/composer/setVariable.html

  1. Use an independent module to store values and access them in the scene and the overlay.

You can access variables in any scene.  There are several ways that come to mind:

  1. Pass a reference to the current scene to the overlay via params.

  2. In the overlay, request a reference to the current scene and then access it.

https://docs.coronalabs.com/daily/api/library/composer/getSceneName.html

https://docs.coronalabs.com/daily/api/library/composer/getScene.html

local currScene = composer.getSceneName( "current" ) -- returns current scene, not overlay composer.removeScene( currScene )
  1. Use the composer variable functions.

https://docs.coronalabs.com/daily/api/library/composer/getVariable.html

https://docs.coronalabs.com/daily/api/library/composer/setVariable.html

  1. Use an independent module to store values and access them in the scene and the overlay.