Storyboard Overlays -- anyone tried them?

I spent a few hours converting an upcoming game from Director to Storyboard now that I have overlays.

So my game uses 3 overlays, correct, wrong and timeout. In every case, it successfully loads the overlay. In my case of Wrong and Timeout, when I click the appropriate button to close the overlay, it closes it and goes back to where it belongs and the game resumes just like it should.

However in the case of “correct”, the screen does not go away. I see a print statement right before the .hideOverlay() call saying it’s closing. I also get this message which I don’t think I’m printing:

The following overlay scene was removed: correct

So from my perspective it should be gone. The game resumes playing underneath it.

I’m not getting any errors. I use the exact same closing and loading code for the other two overlays.

Any other one have any experience with this yet?
[import]uid: 19626 topic_id: 25750 reply_id: 325750[/import]

Sample code? [import]uid: 8271 topic_id: 25750 reply_id: 104158[/import]

No sample yet. I’d have to publish the entire project at this point. I’ve not had a chance to narrow it down yet. [import]uid: 19626 topic_id: 25750 reply_id: 104209[/import]

Well I thought I was on to something. Since my “wrong.lua” and “timeout.lua” overlays work properly but my “correct.lua” doesn’t and the fact that I am using “correct” as a function in the caller and using it as parameters and variables that I might be stomping on something.

I ripped all the code out of correct.lua to do nothing more that show the background image, the dismiss button and it’s call back which calls .hideOverlay().

In addition I renamed the lua file to something other than “correct” and made sure it wasn’t colliding with any variable names.
It still doesn’t remove the overlay and the game starts playing underneath it.

I’m lost.

local storyboard = require( "storyboard" )  
local scene = storyboard.newScene()  
  
local close = function ( event )  
 print("closing")  
 storyboard.hideOverlay()  
end  
  
function scene:createScene( event )  
 local group = self.view  
 local params = event.params  
  
 local questionScore = 0 --params.questionScore  
 local reason = "" -- params.reason  
 local params = event.params  
 if params and type( params ) == "table" then  
 if type( params.score ) == "number" then  
 questionScore = params.score  
 end  
 if type( params.reason ) == "string" then  
 reason = params.reason  
 end  
 end  
  
 local group = display.newGroup()  
 local correctBackground = display.newImageRect("images/correct.jpg", 512, 384)  
 correctBackground.x = display.contentWidth / 2  
 correctBackground.y = display.contentHeight / 2  
 group:insert(correctBackground)   
  
 continueButton = display.newImageRect("images/continue.png", 150, 32)  
 continueButton.x = display.contentWidth / 2  
 continueButton.y = display.contentHeight - 32  
 group:insert(continueButton)  
 continueButton:addEventListener("tap", close)   
end  
  
function scene:enterScene( event )  
 local group = self.view  
  
 local params = event.params  
 if params and type( params ) == "table" then  
 if type( params.score ) == "number" then  
 questionScore = params.score  
 end  
 if type( params.reason ) == "string" then  
 reason = params.reason  
 end  
 end  
end  
  
function scene:exitScene( event )  
 local group = self.view  
end  
  
function scene:destroyScene( event )  
 local group = self.view  
end  
  
scene:addEventListener( "createScene", scene )  
scene:addEventListener( "enterScene", scene )  
scene:addEventListener( "exitScene", scene )  
scene:addEventListener( "destroyScene", scene )  
  
return scene  

Relevant bits from the calling code:

local function correctAnswer()  
 timer.cancel(qTimer);  
 countDown.isVisible = false  
 playerScore = playerScore + 10  
 scoreDisplay:setText(string.format("%07d", playerScore))  
 local options = {  
 effect = "crossFade",  
 time = 250,  
 params = {  
 reason=questionReason,   
 score=questionScore   
 }  
 }  
 storyboard.showOverlay( "correctans", options )  
 return false;  
end  
  

[import]uid: 19626 topic_id: 25750 reply_id: 104545[/import]

  1. Haven’t tried overlay() yet…(hopefully this weekend)
  2. Your close event asks for (event) but doesn’t use it (maybe needed for the event listener to work, I guess?)
  3. You define params twice (:11 and :15)
  4. You define group twice (:10 and :25)
  5. questionScore (:44) and reason (:47) are not previously defined. Possibly not a problem; I’m not really clear on whether you can address variables created in a previous scene event like that, or if you have to declare outside of the scene structure first.

Not convinced any of those will fix your specific problem, but they are things to consider cleaning up… [import]uid: 41884 topic_id: 25750 reply_id: 104719[/import]

Thank you @richard9. You found the problem.

Since I was converting this from Director (localGroup = display.newGroup) to Storyboard (group = self.view) by my redeclaring group, it was a different display group from the one owned by storyboard. I didn’t make this conversion mistake in the others. All is good.

I’ll need to fix up the other problems you spotted!!!

Oh… The not using “event” in the close function. The button is set as a “tap” event and not a touch event. I really don’t need any of the information passed to it so I don’t use it.

As for the two variables declared local in createScene but not declared local in enterScene, would still work, but they would be treated as global variables. I don’t use them outside of the function, so it wouldn’t really matter. But I fixed it to be clear.
[import]uid: 19626 topic_id: 25750 reply_id: 104760[/import]

One last thing, really minor…

AFAIK, display.contentWidth/2 is not exactly the same as display.contentCenterX . In most cases it probably doesn’t matter, but you may want to use the latter for clarity purposes? [import]uid: 41884 topic_id: 25750 reply_id: 104761[/import]

@richard9: Nice catches! I’m glad to see that robmiracle’s problems were identified and were able to be resolved. This community is awesome. [import]uid: 52430 topic_id: 25750 reply_id: 107503[/import]

Actually overlays are working really well for me… as long as I remember to actually add the event listeners for the hide overlay…

I can’t wait to try the new modal options that appeared today so I can remove my background tap catcher…

Storyboard is the awesomeness!
[import]uid: 19626 topic_id: 25750 reply_id: 107509[/import]