Hello! I am new to Storyboard API and got a problem. I want to create a button and go to the next scene when that button is touched.
[lua]
– scene1.lua
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
local background, cherries
local function onSceneTouch( self, event )
if event.phase == “began” then
storyboard.gotoScene( “scene2”, “slideLeft”, 800 )
return true
end
end
function scene:createScene( event )
local screenGroup = self.view
background = display.newImage( “background.png” )
screenGroup:insert( background )
cherries = display.newImage(“cherries.png”)
cherries.x = display.contentWidth / 1.6
cherries.y = display.contentHeight / 2
screenGroup:insert( cherries )
cherries.touch = onSceneTouch
print( “\n1: createScene event”)
end
function scene:enterScene( event )
print( “1: enterScene event” )
end
function scene:exitScene( event )
print( “1: exitScene event” )
cherries:removeEventListener( “touch”, cherries )
end
function scene:destroyScene( event )
print( “((destroying scene 1’s view))” )
end
scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
scene:addEventListener( “exitScene”, scene )
scene:addEventListener( “destroyScene”, scene )
return scene
[/lua]
It doesn’t seem to work properly.
Thank you. [import]uid: 208318 topic_id: 36233 reply_id: 336233[/import]