-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathstart.lua
More file actions
48 lines (36 loc) · 1004 Bytes
/
start.lua
File metadata and controls
48 lines (36 loc) · 1004 Bytes
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
44
45
46
47
48
--start.lua
local physics = require "physics"
physics.start()
local composer = require "composer"
local scene = composer.newScene()
function scene:create(event)
local screenGroup = self.view
startButton = display.newImage("start-button.png")
startButton.x = display.contentWidth * 0.5
startButton.y = display.contentHeight * 0.5
screenGroup:insert(startButton)
end
local function beginGame(event)
if (event.phase == "began") then
composer.gotoScene("game")
end
end
function scene:show(event)
if (event.phase == "will") then
elseif (event.phase == "did") then
startButton:addEventListener("touch", beginGame)
end
end
function scene:hide(event)
if (event.phase == "will") then
startButton:removeEventListener("touch", beginGame)
elseif (event.phase == "did") then
end
end
function scene:destroy(event)
end
scene:addEventListener("create", scene)
scene:addEventListener("show", scene)
scene:addEventListener("hide", scene)
scene:addEventListener("destroy", scene)
return scene