Hi all,
I learned Corona 2 years ago, and now I am trying to pick it back to modify/create my Apps. I reviewed Composer Library page, and feel I can understand better than 2 years ago. Therefore, I kinda try and error Overlay Scenes section and I got 3 questions. I am afraid pasting all code here makes the post too long, so I attach the files.
I made a scene1.lua as the parent scene, and pauseAA.lua as the overlay scene. I think it’s like a dialog pop-up box. I set isModal = false on purpose to test ideas.
Here are 3 questions after I made this practice.
1). About pass and receive parameters between scenes:
In parent scene, I want to pass a table of parameter to child scene. Now the code is working correctly. However, in future, I might have more than one tables of data need to be passed over. Therefore, I named “params” in goPauseOptions a new name, paramsPassOver, and then receive it in child scene by using “local paramsGot = event.paramsPassOver”. Of course, it’s not working. I wonder what’s wrong with my thought?
[[[Working Code block]]]
------------------------------------------------------------------------------ -- In "scene1.lua" (parent scene) ------------------------------------------------------------------------------ local function pause() local goPauseOptions = { effect = "fade", time = 500, isModal = false, params = { passedVar01 = "PASS sample variable", passedVar02 = 8888 } } composer.showOverlay( "pauseAA", goPauseOptions ) end ------------------------------------------------------------------------------ -- In "pauseAA.lua" (child scene) ------------------------------------------------------------------------------ function scene:create( event ) local sceneGroup = self.view local paramsGot = event.params print( paramsGot.passedVar01) print( paramsGot.passedVar02) end
[[[NOT Working Code block]]]
[lua]
– In “scene1.lua” (parent scene)
local function pause()
local goPauseOptions = {
effect = “fade”,
time = 500,
isModal = false,
paramsPassOver = {
passedVar01 = “PASS sample variable”,
passedVar02 = 8888
}
}
composer.showOverlay( “pauseAA”, goPauseOptions )
end
– In “pauseAA.lua” (child scene)
function scene:create( event )
local sceneGroup = self.view
local paramsGot = event.paramsPassOver
print( paramsGot.passedVar01)
print( paramsGot.passedVar02)
end
[/lua]
2). What should I do to make the overlay goes back to parent scene by touching the outside of yellow box area? Like touching the outside of a pop-window to make it disappear?
For visual reference, here is the video that I record earlier before I made the tests of this post. It only show overlay scene and transitions.
In the code I attached here, I tried isModal = false, and made an extra button “Scene1” to receive the tap (it will print “Don’t touch me” in Simulator Console). However, as Corona Documentation mentioned, isModal =true is only to prevent from potentially interacting with the parent scene underneath. How to make the child scene goes away by touching outside of it’s area?
3). I wonder how to make the print result shows on scenes? For example, make the passed parameters 8888 appearing on pauseAA yellow box instead of showing on simulator console?
No matter who answer my questions. Thanks in advance!
Olina