problem with pop-up screens

Hi All,

          I am in the process of building a word game. Whenever I pop-up or display a new screen (overlay on top of the main game screen), the listeners in the bottom main screen are still active. When I choose some action/buttons on the pop-up screen, some times the listeners from the underlying main screen, get activated, resulting in undesired effects. Is there a way to disable the listeners in the main screen before displaying the new screen? I tried the object"removeEventListener and I get “assertion failed” when I try to reactivate the listeners after dismissing the pop-up screen., The native alert screen does work like a charm… Only the buttons on the alert are active and not rest of the device screen. Ideally this is the behavior that I would like to achieve.

-thanks

See isModal option for overlays: http://docs.coronalabs.com/daily/api/library/storyboard/showOverlay.html#ismodal-optional

Hi Jonjonsson,

                    

     Thank you for your response and the link. This was exactly what I needed. However, I am having problems with getting the “scene” stuff working. I have my entire app working from one single main.lua file. Do I need to have one file each for the individual scenes? 

From my main screen which uses only display objects and not scene, I am trying to call a simple scene and getting errors. Any inputs or sample code will help. -thanks

I get this error in simulator:

"File: /Applications/My apps/main.lua

Line: 1238

Attempt to call field ‘gotoscene’ (a nil value)

"

main.lua

========

local storyboard = require “storyboard”  – (almost at the top)

local function cluesL1(event)  

–cluesScr()

storyboard.gotoscene( “scene”, “fade”, 400 ) --calling a simple scene, also tried show overlay

  return true 

end  

scene.lua

=========

local storyboard = require( “storyboard” )

local scene = storyboard.newScene()

local scenebg, sceneRem, sceneShow, sceneBuy, sceneCancel

local function onCancTouch( self, event )

    if event.phase == “began” then

        

        storyboard.purgeScene( “scene”  )

        

        return true

    end

end

– Called when the scene’s view does not exist:

function scene:createScene( event )

    local screenGroup = self.view

 scenebg = display.newImageRect(“cluesbg3.png”, 320, 420)

      scenebg.x = display.contentCenterX;

      scenebg.y = display.contentCenterY;

      screenGroup:insert( scenebg )    

    --image.touch = onSceneTouch

 sceneRem = display.newImageRect(“remletts.png”, 300, 100)

      sceneRem.x = centerX

      sceneRem.y = centerY - 80   

      screenGroup:insert( sceneRem )    

    --sceneRem.touch = onRemTouch     

 sceneShow = display.newImageRect(“showalpha.png”, 300, 100)

      sceneShow.x = centerX

      sceneShow.y = centerY + 20   

      screenGroup:insert( sceneShow )    

    --sceneShow.touch = onShowTouch         

 sceneBuy = display.newImageRect(“buycoins.png”, 100, 80)

      sceneBuy.x = centerX - 60

      sceneBuy.y = centerY + 120  

      screenGroup:insert( sceneBuy )    

    --sceneShow.touch = onShowTouch 

 sceneCancel = display.newImageRect(“cancelbutt.png”, 100, 80)

      sceneCancel.x = centerX + 60

      sceneCancel.y = centerY + 120  

      screenGroup:insert( sceneCancel )    

    sceneCancel.touch = onCancTouch 

 end     

 return scene

====================

Hi, you are using gotoscene instead of gotoScene (capital S). Works if you fix that?

oh my! That fixed the error. The “scene” is not showing up though. 

-thank you

See isModal option for overlays: http://docs.coronalabs.com/daily/api/library/storyboard/showOverlay.html#ismodal-optional

Hi Jonjonsson,

                    

     Thank you for your response and the link. This was exactly what I needed. However, I am having problems with getting the “scene” stuff working. I have my entire app working from one single main.lua file. Do I need to have one file each for the individual scenes? 

From my main screen which uses only display objects and not scene, I am trying to call a simple scene and getting errors. Any inputs or sample code will help. -thanks

I get this error in simulator:

"File: /Applications/My apps/main.lua

Line: 1238

Attempt to call field ‘gotoscene’ (a nil value)

"

main.lua

========

local storyboard = require “storyboard”  – (almost at the top)

local function cluesL1(event)  

–cluesScr()

storyboard.gotoscene( “scene”, “fade”, 400 ) --calling a simple scene, also tried show overlay

  return true 

end  

scene.lua

=========

local storyboard = require( “storyboard” )

local scene = storyboard.newScene()

local scenebg, sceneRem, sceneShow, sceneBuy, sceneCancel

local function onCancTouch( self, event )

    if event.phase == “began” then

        

        storyboard.purgeScene( “scene”  )

        

        return true

    end

end

– Called when the scene’s view does not exist:

function scene:createScene( event )

    local screenGroup = self.view

 scenebg = display.newImageRect(“cluesbg3.png”, 320, 420)

      scenebg.x = display.contentCenterX;

      scenebg.y = display.contentCenterY;

      screenGroup:insert( scenebg )    

    --image.touch = onSceneTouch

 sceneRem = display.newImageRect(“remletts.png”, 300, 100)

      sceneRem.x = centerX

      sceneRem.y = centerY - 80   

      screenGroup:insert( sceneRem )    

    --sceneRem.touch = onRemTouch     

 sceneShow = display.newImageRect(“showalpha.png”, 300, 100)

      sceneShow.x = centerX

      sceneShow.y = centerY + 20   

      screenGroup:insert( sceneShow )    

    --sceneShow.touch = onShowTouch         

 sceneBuy = display.newImageRect(“buycoins.png”, 100, 80)

      sceneBuy.x = centerX - 60

      sceneBuy.y = centerY + 120  

      screenGroup:insert( sceneBuy )    

    --sceneShow.touch = onShowTouch 

 sceneCancel = display.newImageRect(“cancelbutt.png”, 100, 80)

      sceneCancel.x = centerX + 60

      sceneCancel.y = centerY + 120  

      screenGroup:insert( sceneCancel )    

    sceneCancel.touch = onCancTouch 

 end     

 return scene

====================

Hi, you are using gotoscene instead of gotoScene (capital S). Works if you fix that?

oh my! That fixed the error. The “scene” is not showing up though. 

-thank you