When I push a button to make an overlap appear over my scene, I can still interact with all the objects in the scene that the overlay is covering, I can still drag a ball around the screen etc. Is there a way that when the overlay comes down I can interact with the objects behind it?
Here is my overlay code
local composer = require( "composer" ) local scene = composer.newScene() ---------------------------------------------------------------------- -- LOCALS -- ---------------------------------------------------------------------- -- Variables local w = display.contentWidth local h = display.contentHeight local centerX = display.contentCenterX local centerY = display.contentCenterY local back -- Forward Declarations -- Useful Localizations local mAbs = math.abs local mRand = math.random local mDeg = math.deg local mRad = math.rad local mCos = math.cos local mSin = math.sin local mAcos = math.acos local mAsin = math.asin local mSqrt = math.sqrt local mCeil = math.ceil local mFloor = math.floor local mAtan2 = math.atan2 local mPi = math.pi local getInfo = system.getInfo local getTimer = system.getTimer local strMatch = string.match local strFormat = string.format local pairs = pairs ---------------------------------------------------------------------- -- Scene Methods ---------------------------------------------------------------------- ---------------------------------------------------------------------- ---------------------------------------------------------------------- function scene:create( event ) local sceneGroup = self.view -- Create a simple background back = display.newRect( sceneGroup, centerX, centerY, 10000, 10000 ) back:setFillColor( 0, 0, 0 ) if(w\>h) then back.rotation = 90 end back.alpha = 0.3 -- Create a label showing which scene this is local label = display.newEmbossedText( sceneGroup, "Game Paused", centerX, 40, native.systemFont, 60 ) label:setFillColor( 0xCC/255, 1, 1 ) local color = { highlight = { r=1, g=1, b=1 }, shadow = { r=0, g=1, b=0.3 } } label:setEmbossColor( color ) local widget = require( "widget" ) -- Function to handle button events local function handleButtonEvent( event ) composer.gotoScene( "ifc.mainMenu", options ) if ( "ended" == event.phase ) then print( "Button was pressed and released" ) end end local mainmenu = widget.newButton( { width = 120, height = 60, defaultFile = "images/pause.png", overFile = "images/resume.png", label = "", onEvent = handleButtonEvent } ) -- Center the button mainmenu.x = display.contentCenterX mainmenu.y = display.contentCenterY -- Change the button's label text mainmenu:setLabel( "Main Menu" ) sceneGroup:insert(mainmenu) local widget = require( "widget" ) -- Function to handle button events local function handleButtonEvent( event ) physics:start() composer.hideOverlay( "ifc.pause", options ) if ( "ended" == event.phase ) then print( "Button was pressed and released" ) end end local resume = widget.newButton( { width = 60, height = 30, defaultFile = "images/pause.png", overFile = "images/resume.png", label = "", onEvent = handleButtonEvent } ) -- Center the button resume.x = 300 resume.y = 20 -- Change the button's label text resume:setLabel( "Pause" ) sceneGroup:insert(resume) end ---------------------------------------------------------------------- ---------------------------------------------------------------------- function scene:willEnter( event ) local sceneGroup = self.view transition.to( back, { alpha = 0.8, time = 500 } ) end ---------------------------------------------------------------------- ---------------------------------------------------------------------- function scene:didEnter( event ) local sceneGroup = self.view end ---------------------------------------------------------------------- ---------------------------------------------------------------------- function scene:willExit( event ) local sceneGroup = self.view transition.to( back, { alpha = 0, time = 300 } ) end ---------------------------------------------------------------------- ---------------------------------------------------------------------- function scene:didExit( event ) local sceneGroup = self.view end ---------------------------------------------------------------------- ---------------------------------------------------------------------- function scene:destroy( event ) local sceneGroup = self.view back = nil end ---------------------------------------------------------------------- -- FUNCTION/CALLBACK DEFINITIONS -- ---------------------------------------------------------------------- ----------------------------- -- Scene Dispatch Events, Etc. - Generally Do Not Touch Below This Line --------------------------------------------------------------------------------- function scene:show( event ) local sceneGroup = self.view local willDid = event.phase if( willDid == "will" ) then self:willEnter( event ) elseif( willDid == "did" ) then self:didEnter( event ) end end function scene:hide( event ) local sceneGroup = self.view local willDid = event.phase if( willDid == "will" ) then self:willExit( event ) elseif( willDid == "did" ) then self:didExit( event ) end end scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) --------------------------------------------------------------------------------- return scene