I’ve been trying to get the scene to change off of a “Tap to Start” type screen. I’ve went through a bunch of tutorials on setting up the listeners and how to change a scene but I can’t seem to get it to work. I’ve tried setting an event listener to the background, text, and a runtime event but it hasn’t worked for me yet. Could someone help me out? Perhaps show me how to do it or just point me in the direction of a tutorial that could show me how.
What are you using for your button?
I have this right now.
local touchToStart = display.newText( “>>> Tap to Begin Flight <<<”, 320/2, 420, “uni 05_63”, 16)
Could I use a text as a button? or the background image?
You can use a display.newText for this, but if you want features like showing that it’s been tapped by changing colors, etc. you should check out widget.newButton().
But lets go with what you have:
local touchToStart = display.newText( “>>> Tap to Begin Flight <<<”, 320/2, 420, “uni 05_63”, 16)
local function onTouch( event )
if event.phase == “ended” then
composer.gotoScene(“yourotherscene”)
end
return true
end
touchToStart:addEventListener(“touch”, onTouch)
Thank you so much!
What are you using for your button?
I have this right now.
local touchToStart = display.newText( “>>> Tap to Begin Flight <<<”, 320/2, 420, “uni 05_63”, 16)
Could I use a text as a button? or the background image?
You can use a display.newText for this, but if you want features like showing that it’s been tapped by changing colors, etc. you should check out widget.newButton().
But lets go with what you have:
local touchToStart = display.newText( “>>> Tap to Begin Flight <<<”, 320/2, 420, “uni 05_63”, 16)
local function onTouch( event )
if event.phase == “ended” then
composer.gotoScene(“yourotherscene”)
end
return true
end
touchToStart:addEventListener(“touch”, onTouch)
Thank you so much!