/
menu.lua
97 lines (82 loc) · 2.22 KB
/
menu.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
module(..., package.seeall)
local radlib = require "radlib"
-- Main function - MUST return a display.newGroup()
function new()
local ui = require("ui")
local localGroup = display.newGroup()
-- Background
local background = display.newImageRect("bk_default.png", 480, 320)
background.x = display.contentCenterX
background.y = display.contentCenterY
localGroup:insert(background)
-- Menu Buttons - Start
local playButton = nil
local function onPlayPressed ( event )
if event.phase == "ended" and playButton.isActive then
director:changeScene("play", "fade", 30.0,60.0,90.0)
end
end
playButton = ui.newButton(
radlib.tableMerge(
_G.buttons['play'],
{ onRelease = onPlayPressed }
)
)
playButton.x = 160
playButton.y = 80
playButton.isActive = true
localGroup:insert(playButton)
local settingsButton = nil
local function onSettingsPressed ( event )
if event.phase == "ended" and settingsButton.isActive then
director:changeScene("settings", "fade", "green")
end
end
settingsButton = ui.newButton(
radlib.tableMerge(
_G.buttons['settings'],
{ onRelease = onSettingsPressed }
)
)
settingsButton.x = 160
settingsButton.y = 130
settingsButton.isActive = true
localGroup:insert(settingsButton)
local helpButton = nil
local function onHelpPressed ( event )
if event.phase == "ended" and helpButton.isActive then
director:changeScene("help", "overFromTop")
end
end
helpButton = ui.newButton(
radlib.tableMerge(
_G.buttons['help'],
{ onRelease = onHelpPressed }
)
)
helpButton.x = 160
helpButton.y = 180
helpButton.isActive = true
localGroup:insert(helpButton)
local aboutButton = nil
local function onAboutPressed ( event )
if event.phase == "ended" and aboutButton.isActive then
director:changeScene("about", "moveFromLeft")
end
end
aboutButton = ui.newButton(
radlib.tableMerge(
_G.buttons['about'],
{ onRelease = onAboutPressed }
)
)
aboutButton.x = 160
aboutButton.y = 230
aboutButton.isActive = true
localGroup:insert(aboutButton)
-- Menu Buttons - End
unloadMe = function()
end
-- MUST return a display.newGroup()
return localGroup
end