Transition from the menu scene to the game scene with a button. When the button is pressed the menu transitions to the game scene, but the text from the menu scene is not clearing. The button is cleared, but not the text. Expected to have a blank state to work with.
function scene:create( event ) local sceneGroup = self.view -- Add scene display objects to this group -- fill the background to a color local background = display.newRect( sceneGroup, 0, 0, actualWidth, actualHeight) background.x = width \* 0.5 background.y = height \* 0.5 background:setFillColor( 208/255,244/255,247/255 ) -- gametitle on the top center local titleText = { text = "Game Title", x = actualWidth / 2, y = actualHeight / 4, width = 100, height = 200, font = native.systemFont, fontsize = 50, align = "center" } local gameTitle = display.newText( titleText ) gameTitle:setFillColor( 0.6, 0.4, 0.8 ) -- scene transition to game button local function onPlayTouch( event ) if ( "ended" == event.phase ) then composer.gotoScene( "scene.game", "slideLeft" ) end end local playButton = widget.newButton { defaultFile = "scene/menu/ui/touch.png", onEvent = onPlayTouch } playButton.x = actualWidth / 2 playButton.y = actualHeight / 2 sceneGroup:insert( playButton ) end
The game.lua file is the just the composer template. The rest of the menu.lua code is also the composer template.