–requires
local composer = require( “composer” )
local scene = composer.newScene()
local function gotoGame()
composer.gotoScene( “game”, { time=800, effect=“crossFade” } )
end
– background
local startb= display.newImageRect( “startb.png”, 575, 320 )
startb.x = 240
startb.y = 160
local name= display.newImageRect( “title.png”, 400, 100 )
name.x = 240
name.y = 60
local submarine= display.newImageRect( “submarinee.png”, 120, 90 )
submarine.x = 430
submarine.y = 100
local startbutton= display.newImageRect( “Startbutton.png”, 100, 45 )
startbutton.x = 250
startbutton.y = 150
startbutton:addEventListener( “tap”, gotoGame )
– *************************Scene event functions**********************
– create()
function scene:create( event )
local sceneGroup = self.view
startb= display.newImageRect( “startb.png”, 575, 320 )
startb.x = 240
startb.y = 160
sceneGroup:insert( startb )
name= display.newImageRect( “title.png”, 400, 100 )
name.x = 240
name.y = 60
sceneGroup:insert( name )
submarine= display.newImageRect( “submarinee.png”, 120, 90 )
submarine.x = 430
submarine.y = 100
sceneGroup:insert( submarine )
startbutton= display.newImageRect( “Startbutton.png”, 100, 45 )
startbutton.x = 250
startbutton.y = 150
sceneGroup:insert( startbutton )
startbutton:addEventListener( “tap”, gotoGame)
end
–show
function scene:showScene( event )
local sceneGroup = self.view
local phase = event.phase
if ( phase == “will” ) then
– Code here runs when the scene is still off screen (but is about to come on screen)
elseif ( phase == “did” ) then
– Code here runs when the scene is entirely on screen
end
end
function scene:hideScene( event )
local sceneGroup = self.view
local phase = event.phase
if ( phase == “will” ) then
– Code here runs when the scene is on screen (but is about to go off screen)
elseif ( phase == “did” ) then
– Code here runs immediately after the scene goes entirely off screen
end
end
–destroy()
function scene:destroyScene( event )
local sceneGroup = self.view
end
scene:addEventListener(“createScene”, scene)
scene:addEventListener(“showScene”, scene)
scene:addEventListener(“hideScene”, scene)
scene:addEventListener(“destroyScene”, scene)
return scene