Hi
I implemented sucessful a simple checkbox switch overlay scene. They only remember their state when not inserted in self.view. A checkbox with a custom sheet never remembers its state inserted in self.view or not.
Is this a bug?
It did a test: When converting the overlay scene in a normal scene, the checkbox remembers its state.
Here’s some code:
local sceneName = optionssw local composer = require( "composer" ) local scene = composer.newScene() widget = require( "widget" ) function scene:create( event ) function musicswitch( event ) local switch = event.target if (switch.isOn) then audio.resume(bgmusic) else audio.pause(bgmusic) end end local options = { width = 100, height = 100, numFrames = 2, sheetContentWidth = 200, sheetContentHeight = 100 } local checkboxSheet = graphics.newImageSheet( "checkonoff.png", options ) -- Create the widget checkbox = widget.newSwitch { left = 850, top = 640, style = "checkbox", id = "Checkbox1", width = 80, height = 80, onPress = musicswitch, sheet = checkboxSheet, frameOff = 1, frameOn = 2, initialSwitchState = true } gruppop:insert(checkbox) end function scene:hide( event ) local phase = event.phase local parent = event.parent --reference to the parent scene object if ( phase == "will" ) then parent:resumeGame() end end scene:addEventListener( "create", scene ) scene:addEventListener( "hide", scene ) return scene
this overlay scene is called by this:
if optionslua==0 then local options = { isModal = false, effect = "fade", time = 400, } composer.showOverlay( "optionssw", options ) end
isModal shall be false, because the options field is small and the user can continue by pressing buttons on the lower scene.
Thanks
Olivier