Help to change scenes by button please :unsure:
Using the standard composer scene template as a starting point:
local composer = require( "composer" ) local scene = composer.newScene() local widget = require( "widget" ) local utility = require( "utility" ) local params local function handleChangeButton( event ) if event.phase == "ended" then composer.gotoScene( "someotherscene", { effect = "crossFade", time = 500 } ) end return true end -- -- Start the composer event handlers -- function scene:create( event ) local sceneGroup = self.view params = event.params -- -- setup a page background, really not that important though composer -- crashes out if there isn't a display object in the view. -- local changeButton = widget.newButton({ lable = "Change Scenes", onEvent = handleChangeButton }) sceneGroup:insert( changeButton ) changeButton.x = display.contentCenterX changeButton.y = display.contentCenterY end function scene:show( event ) local sceneGroup = self.view params = event.params if event.phase == "did" then end end function scene:hide( event ) local sceneGroup = self.view if event.phase == "will" then end end function scene:destroy( event ) local sceneGroup = self.view end --------------------------------------------------------------------------------- -- END OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) return scene
Using the standard composer scene template as a starting point:
local composer = require( "composer" ) local scene = composer.newScene() local widget = require( "widget" ) local utility = require( "utility" ) local params local function handleChangeButton( event ) if event.phase == "ended" then composer.gotoScene( "someotherscene", { effect = "crossFade", time = 500 } ) end return true end -- -- Start the composer event handlers -- function scene:create( event ) local sceneGroup = self.view params = event.params -- -- setup a page background, really not that important though composer -- crashes out if there isn't a display object in the view. -- local changeButton = widget.newButton({ lable = "Change Scenes", onEvent = handleChangeButton }) sceneGroup:insert( changeButton ) changeButton.x = display.contentCenterX changeButton.y = display.contentCenterY end function scene:show( event ) local sceneGroup = self.view params = event.params if event.phase == "did" then end end function scene:hide( event ) local sceneGroup = self.view if event.phase == "will" then end end function scene:destroy( event ) local sceneGroup = self.view end --------------------------------------------------------------------------------- -- END OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) return scene