-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.lua
113 lines (98 loc) · 3.09 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
local ui = require "scripts.lib.ui"
local radlib = require "scripts.lib.radlib"
---------------------------------------------------------------------------------
-- BEGINNING OF YOUR IMPLEMENTATION
---------------------------------------------------------------------------------
local screen = nil
function scene:createScene( event )
screen = self.view
local startButton = nil
local function onStartPressed ( event )
if event.phase == "ended" and startButton.isActive then
storyboard.gotoScene( "start" )
end
end
startButton = ui.newButton(
radlib.table.merge(
_G.buttons['start'],
{ onRelease = onStartPressed }
)
)
startButton.x = 160
startButton.y = 80
startButton.isActive = true
screen:insert(startButton)
local settingsButton = nil
local function onSettingsPressed( event )
if event.phase == "ended" and settingsButton.isActive then
storyboard.gotoScene( "settings" )
end
end
settingsButton = ui.newButton(
radlib.table.merge(
_G.buttons['settings'],
{ onRelease = onSettingsPressed }
)
)
settingsButton.x = 160
settingsButton.y = 130
settingsButton.isActive = true
screen:insert(settingsButton)
local aboutButton = nil
local function onAboutPressed( event )
if event.phase == "ended" and aboutButton.isActive then
storyboard.gotoScene( "about" )
end
end
aboutButton = ui.newButton(
radlib.table.merge(
_G.buttons['about'],
{ onRelease = onAboutPressed }
)
)
aboutButton.x = 160
aboutButton.y = 180
aboutButton.isActive = true
screen:insert(aboutButton)
local helpButton = nil
local function onHelpPressed( event )
if event.phase == "ended" and helpButton.isActive then
storyboard.gotoScene( "help" )
end
end
helpButton = ui.newButton(
radlib.table.merge(
_G.buttons['help'],
{ onRelease = onHelpPressed }
)
)
helpButton.x = 160
helpButton.y = 230
helpButton.isActive = true
screen:insert(helpButton)
end
function scene:enterScene( event )
print("Menu loaded...")
end
function scene:exitScene( event )
end
function scene:destroyScene( event )
end
---------------------------------------------------------------------------------
-- END OF YOUR IMPLEMENTATION
---------------------------------------------------------------------------------
--
-- "createScene" event is dispatched if scene's view does not exist
scene:addEventListener( "createScene", scene )
-- "enterScene" event is dispatched whenever scene transition has finished
scene:addEventListener( "enterScene", scene )
-- "exitScene" event is dispatched before next scene's transition begins
scene:addEventListener( "exitScene", scene )
-- "destroyScene" event is dispatched before view is unloaded, which can be
-- automatically unloaded in low memory situations, or explicitly via a call to
-- storyboard.purgeScene() or storyboard.removeScene().
scene:addEventListener( "destroyScene", scene )
---------------------------------------------------------------------------------
return scene