Other ways of calling functions from parents through overlaysThe

Hi there. Is there any alternative way of calling parent scene’s function from it’s overlay scene?
This is the example iget from: https://docs.coronalabs.com/guide/system/composer/index.html

Is there any substitute or alternative way? Which instead of:

local composer = require ( "composer" )

local scene = composer.newScene()

function scene:hide( event )

local sceneGroup = self.view

local phase = event.phase

local parent = event.parent --reference to the parent scene object

if ( phase == "will" ) then

-- Call the "resumeGame()" function in the parent scene

parent:resumeGame()

end

end

-- By some method (a "resume" button, for example), hide the overlay

composer.hideOverlay( "fade" , 400 )

scene:addEventListener( "hide" , scene )

return scene

or can I call this in create listener like:

local composer = require ( "composer" )

local scene = composer.newScene()

function scene:create( event )

local sceneGroup = self.view

local phase = event.phase

local parent = event.parent --reference to the parent scene object

if ( phase == "will" ) then

-- Call the "resumeGame()" function in the parent scene

parent:resumeGame()

end

end

-- By some method (a "resume" button, for example), hide the overlay

composer.hideOverlay( "fade" , 400 )

scene:addEventListener( "create" , scene )

return scene

But in different ways? Thank you.

The way how you can comment code in the forums is the same as in Discord or GitHub, i.e. via backticks `

```lua
If you paste your code between two lines with three backticks, like this, then it’ll get formatted as code.
```

local var = "yay!"

Another, perhaps more convenient method, is to use modules. You can have a module that you require in your overlay scene and regular scene. In the module, you set callback function that will be called from the overlay scene and the callback function triggers something in the regular scene.

Ticks:

local var = "yay!"

or 4 spaces to start

local var = "yay!"

Thank you very much.

If you know where the overlay is coming from you can use parent:

local parent = nil
...
function scene:show(event)
   local sceneGroup = self.view
   parent = event.parent 
end

and call a parent function someplace else:

parent:overlayAction()  

But in most cases I don’t know where the overlay is coming so I just fire a callback as @XeduR mentioned.