Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Taps not detecting after overlay
Started by fwcarlitos Aug 17 2017 12:47 PM

6 replies to this topic
composer scenes overlay tap

Best Answer yvandotet , 18 August 2017 - 07:45 AM

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.

[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

fwcarlitos

[GLOBAL: userInfoPane.html]
fwcarlitos
  • Enthusiast

  • 62 posts
  • Corona SDK

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!



[TOPIC: post.html]
#2

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

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



[TOPIC: post.html]
#3

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Remember to surround any code with "lua" tags too, for clarity in the forums:

[lua]
-- code
[/lua]


[TOPIC: post.html]
#4

fwcarlitos

[GLOBAL: userInfoPane.html]
fwcarlitos
  • Enthusiast

  • 62 posts
  • Corona SDK

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.



[TOPIC: post.html]
#5

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,460 posts
  • Enterprise

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



[TOPIC: post.html]
#6

yvandotet

[GLOBAL: userInfoPane.html]
yvandotet
  • Contributor

  • 184 posts
  • Corona SDK

  Best Answer

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.



[TOPIC: post.html]
#7

fwcarlitos

[GLOBAL: userInfoPane.html]
fwcarlitos
  • Enthusiast

  • 62 posts
  • Corona SDK

Thanks so much for your help!




[topic_controls]
[/topic_controls]