composer overlay issue

Hi :slight_smile:

Currently using the composer to overlay a scene on top of another scene, and set the isModal = true, but the object in original scene still touchable and functioning.

3 files : 

  1. a file that contain the same coding for each scene (storing the sidebar menu coding)

  2. original scene (behind)

  3. child scene (overlay)

file 1 : (part of the coding to call the overlay scene)

[lua]

function iconListener1( event )

    if ( event.phase == “moved” ) then

        local dx = math.abs(event.x - event.xStart ) 

        if ( dx > 5 ) then

            scrollView:takeFocus( event ) 

        end

        local options = {

        effect = “fade”,

        time = 100,

        isModal = true

        }

    elseif ( event.phase == “ended” ) then

         print (“Go to scene menu from sidebar”)

         composer.showOverlay(“map”,options)

         timer.performWithDelay( 10, function() scrollView:removeSelf(); scrollView = nil; end )

         print (“Close sidebar”)

return true

end

return true

end

[/lua]

file 2 : just been overlay and touchable, functioning. nothing related with overlay, a normal scene.

file 3 : (part of the coding that close the overlay back)

[lua]

local function goBack(event)

if event.phase == “ended” then

composer.hideOverlay(“fade”,100)

print (“Close overlay scene”)

end

return true

end

[/lua]

*each scene shared same code : (I really doesn’t know what should I write in the show and hide function, so is left empty)

[lua]

function scene:show(event)

end

function scene:hide(event)

end

function scene:destroy(event)

self.view = nil

end

[/lua]

Why the object behind the scene still respond to the touch? It has been overlay-ed but is functioning (like overlapping) even the isModal = true was set.

Please Please Please help me on this issue, am cracking my head :frowning:

Thanks for the helps :slight_smile:

Bumping the post…

The scene was overlayed and shown on the screen, but when I press the items behind (because the overlay scene was a bit transparent)

it did function eg. go to next scene.

Since the isModal set to true. like :

[lua]

local options = {

effect = “fade”,

time = 100,

isModal = true

}

elseif ( event.phase == “ended” ) then

composer.showOverlay(“map”,options) 

end

[/lua]

it should be avoid the touches passing to the scene and items behind right?

Please help me clarify on this :frowning: What’s the theory behind?

Based on my understanding, the isModal = true should work for this but it didn’t…

no error message was prompt.

:unsure:

You look like you have a scope problem.  You define “local options” inside of an if block.  But you try to use it inside of an elseif block.  The way you defined the options in the if block makes it only visible to the if block.  In effect in the elseif block, you’re passing nil in for options, so it’s not settings .isModal

Rob

And I am like,  :smiley:  Thanksssssssssssss Rob!!!

Have a wonderful day :smiley:

Bumping the post…

The scene was overlayed and shown on the screen, but when I press the items behind (because the overlay scene was a bit transparent)

it did function eg. go to next scene.

Since the isModal set to true. like :

[lua]

local options = {

effect = “fade”,

time = 100,

isModal = true

}

elseif ( event.phase == “ended” ) then

composer.showOverlay(“map”,options) 

end

[/lua]

it should be avoid the touches passing to the scene and items behind right?

Please help me clarify on this :frowning: What’s the theory behind?

Based on my understanding, the isModal = true should work for this but it didn’t…

no error message was prompt.

:unsure:

You look like you have a scope problem.  You define “local options” inside of an if block.  But you try to use it inside of an elseif block.  The way you defined the options in the if block makes it only visible to the if block.  In effect in the elseif block, you’re passing nil in for options, so it’s not settings .isModal

Rob

And I am like,  :smiley:  Thanksssssssssssss Rob!!!

Have a wonderful day :smiley: