So I have a basic game set up. Whenever the player taps, an overlay is shown that allows the player to edit certain settings related to the game itself (I don’t want a button for this due to the nature of the game). However, if the player taps a second time, the overlay does not show up. I added a print statement to the beginning of the tap detector, and it does not print in the console. I have tap listeners added to every display object on the screen and to Runtime, but it still does not show up. Is it possible the problem is related to the fact that I add all the elements of the overlay in scene:create, but I never call scene:destroy? If so, what should I do about that? Any and all help appreciated. Thanks so much!
Hi @fwcarlitos,
There are too many factors to solve this without seeing your basic code. Many things could be going on, so please post some basic code that shows how you’ve set things up. If possible, try to post a “shorter” version, because most time we ask people to post Composer-related code, it ends up being like 300 lines of hard-to-follow code, most of it unrelated to the actual issue.
Thanks,
Brent
Remember to surround any code with “lua” tags too, for clarity in the forums:
[lua] -- code [/lua]
Here is the code:
[lua] --------------------loadGame.lua-------------------- local function onTap(event) print("tap") physics.removeBody(player) physics.pause() local options = { isModal = true, effect = "fade", time = 400, params = { player = player } } composer.showOverlay("scenes.editSettings", options) end function scene:show( event ) local sceneGroup = self.view local phase = event.phase if phase == "did" then map:addEventListener( "tap", onTap ) background:addEventListener("tap", onTap) player:addEventListener("tap", onTap) Runtime:addEventListener("tap", onTap)--I added all the different tap listeners in an attempt to get the tap to be detected, but it didnt work onTap()--enters settings menu at start of level end end --------------------editSettings.lua-------------------- local function onDoneBtnRelease() composer.hideOverlay( "fade", 400 ) return true end function scene:create( event ) --mostly text fields here doneBtn = widget.newButton{ label="Done", labelColor = { default={255}, over={128} }, width=154, height=40, onRelease = onDoneBtnRelease -- event listener function } end function scene:hide( event ) local sceneGroup = self.view local phase = event.phase local parent = event.parent -- Reference to the parent scene object if (phase == "did") then physics.addBody(player, { density=1, friction=0, bounce=player.bounce }) physics.setGravity(player.Xgravity, player.Ygravity) physics.start() end end [/lua]
I tried to only include the relevant code, but if I left something out, just let me know. I should add that when I remove onTap() from scene:show, I can tap once. When I have onTap() called at the beginning, I can’t call it ever again. Sorry for the poor code structure, I haven’t been doing this very long.
What version of Corona are you using?
Can you zip up your whole project and share a link with us so we can see the entire flow?
Thanks
Rob
With the isModal property is true for the overlay, the overlay add a fake event which return true when you tap or touch behind the scene.
Try with “isModal” key equal to false.
Thanks so much for your help!
Hi @fwcarlitos,
There are too many factors to solve this without seeing your basic code. Many things could be going on, so please post some basic code that shows how you’ve set things up. If possible, try to post a “shorter” version, because most time we ask people to post Composer-related code, it ends up being like 300 lines of hard-to-follow code, most of it unrelated to the actual issue.
Thanks,
Brent
Remember to surround any code with “lua” tags too, for clarity in the forums:
[lua] -- code [/lua]
Here is the code:
[lua] --------------------loadGame.lua-------------------- local function onTap(event) print("tap") physics.removeBody(player) physics.pause() local options = { isModal = true, effect = "fade", time = 400, params = { player = player } } composer.showOverlay("scenes.editSettings", options) end function scene:show( event ) local sceneGroup = self.view local phase = event.phase if phase == "did" then map:addEventListener( "tap", onTap ) background:addEventListener("tap", onTap) player:addEventListener("tap", onTap) Runtime:addEventListener("tap", onTap)--I added all the different tap listeners in an attempt to get the tap to be detected, but it didnt work onTap()--enters settings menu at start of level end end --------------------editSettings.lua-------------------- local function onDoneBtnRelease() composer.hideOverlay( "fade", 400 ) return true end function scene:create( event ) --mostly text fields here doneBtn = widget.newButton{ label="Done", labelColor = { default={255}, over={128} }, width=154, height=40, onRelease = onDoneBtnRelease -- event listener function } end function scene:hide( event ) local sceneGroup = self.view local phase = event.phase local parent = event.parent -- Reference to the parent scene object if (phase == "did") then physics.addBody(player, { density=1, friction=0, bounce=player.bounce }) physics.setGravity(player.Xgravity, player.Ygravity) physics.start() end end [/lua]
I tried to only include the relevant code, but if I left something out, just let me know. I should add that when I remove onTap() from scene:show, I can tap once. When I have onTap() called at the beginning, I can’t call it ever again. Sorry for the poor code structure, I haven’t been doing this very long.
What version of Corona are you using?
Can you zip up your whole project and share a link with us so we can see the entire flow?
Thanks
Rob
With the isModal property is true for the overlay, the overlay add a fake event which return true when you tap or touch behind the scene.
Try with “isModal” key equal to false.
Thanks so much for your help!