Im a beginner to the Corona SDK.
I have 2 scenes A & B.
In scene A i have a button with a OnRelease event.
This button is created and added to the group in the scene Create event.
Clicking the button takes me to scene B ( storyboard.gotoScene(“B”) ).
In scene B i have a touch event on an box (crate image).
The touch listener is added in the scene Started event, and removed in the scene Exited event.
Clicking on the crate takes me back to A ( storyboard.gotoScene(“A”) ).
So here’s the real annoying issue:
After going back to A, all events in this scene are now disabled.
i.e. I can no longer click on the button any more (no event).
Will provide code snippet if I am missing information above.
Thank you.
* Update *
After taking about a break from this, i went back today and started debugging this again. I found the issue fairly quickly. The problem had something to do with my touched event handler (which causes a transition from scene B to A).
snippet below that caused the issue:
function testTouched( event )
-- process cue-touched event...
--local t = event.target -- commenting this was the fix.
local phase = event.phase
if "began" == phase then
print(" -> back to menu")
--display.getCurrentStage():setFocus( t ) -- commenting this was the fix.
--t.isFocus = true -- commenting this was the fix.
storyboard.gotoScene( "menu", "flipFadeOutIn", 500 )
end
-- Stop further propagation of touch event
return true
From what I see here,
Add event listeners in
enterScene()event rather thancreateScene()and remove them atexitScene()?Edit: I think you would need to
display.getCurrentStage():setFocus(nil)inexitScene().