-
Notifications
You must be signed in to change notification settings - Fork 2
/
start.lua
executable file
·46 lines (34 loc) · 1.23 KB
/
start.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
local composer = require( "composer" )
local scene = composer.newScene()
local startButton -- used to start the game
local pulsatingText = require("pulsatingtext") -- A module providing a pulsating text effect
local starFieldGenerator = require("starfieldgenerator") -- A module that generates the starFieldGenerator
local starGenerator -- An instance of the starFieldGenerator
function scene:create( event )
local group = self.view
startButton = display.newImage("new_game_btn.png",display.contentCenterX,display.contentCenterY+100)
group:insert(startButton)
end
function scene:show( event )
local phase = event.phase
local previousScene = composer.getSceneName( "previous" )
if(previousScene~=nil) then
composer.removeScene(previousScene)
end
if ( phase == "did" ) then
startButton:addEventListener("tap",startGame)
end
end
function scene:hide( event )
local phase = event.phase
if ( phase == "will" ) then
startButton:removeEventListener("tap",startGame)
end
end
function startGame()
composer.gotoScene("gamelevel")
end
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
return scene