local storyboard = require ("storyboard") local scene = storyboard.newScene() local cambio = 0 local tasto1 --\<---- make it local here so all children functions can see it. function scene:createScene(event) local group = self.view local gameMusic = audio.loadStream( "base\_ballshot.mp3" ) local background\_start = display.newImage("Menubackground.png") background\_start.x = display.contentWidth \* 0.5 background\_start.y = 230 group:insert(background\_start) tasto1 = display.newImage("tastostart.png") --\<----- take off the local here tasto1.x = display.contentWidth \* 0.5 -180 tasto1.y = 250 --local gameMusicChannel = audio.play( gameMusic, { loops = -1 } ) end function start(event) if event.phase == "began" then storyboard.gotoScene("livello1", "fade", 400) storyboard.purgeScene("start") end end function scene:enterScene(event) storyboard.purgeScene("gameover") tasto1:addEventListener("touch", start) end function scene:exitScene(event) tasto1:removeEventListener("touch", start) end function scene:destroyScene(event) end scene:addEventListener("createScene", scene) scene:addEventListener("enterScene", scene) scene:addEventListener("exitScene", scene) scene:addEventListener("destroyScene", scene) return scene
I made two changes to illustrate this. Look for the two lines with --<-------