-
Notifications
You must be signed in to change notification settings - Fork 1
/
difficultyscene.lua
99 lines (79 loc) · 2 KB
/
difficultyscene.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
local composer = require( "composer" )
local scene = composer.newScene()
local widget = require "widget"
local easyBtn
local hardBtn
local impossibleBtn
local difficulty
local function onBtnRelease(event)
composer.gotoScene( "characterselect", {
effect = "fade",
time = 400,
params = {
difficulty = difficulty
}
} )
return true -- indicates successful touch
end
local function onEasyBtn()
difficulty = 1
onBtnRelease()
end
local function onHardBtn()
difficulty = 2
onBtnRelease()
end
local function onImpossibleBtn()
difficulty = 3
onBtnRelease()
end
function scene:create( event )
local sceneGroup = self.view
easyBtn = widget.newButton{
label = "EASY",
width=154, height=40,
onRelease = onEasyBtn
}
easyBtn.x = display.contentCenterX
easyBtn.y = display.contentHeight - 125
hardBtn = widget.newButton{
label = "HARD",
width=154, height=40,
onRelease = onHardBtn
}
hardBtn.x = display.contentCenterX
hardBtn.y = display.contentHeight - 225
impossibleBtn = widget.newButton{
label = "IMPOSSIBLE",
width=154, height=40,
onRelease = onImpossibleBtn
}
impossibleBtn.x = display.contentCenterX
impossibleBtn.y = display.contentHeight - 325
sceneGroup:insert( easyBtn )
sceneGroup:insert( hardBtn )
sceneGroup:insert( impossibleBtn )
end
function scene:show( event )
local sceneGroup = self.view
local phase = event.phase
end
function scene:hide( event )
local sceneGroup = self.view
local phase = event.phase
end
function scene:destroy( event )
local sceneGroup = self.view
easyBtn:removeSelf() -- widgets must be manually removed
easyBtn = nil
hardBtn:removeSelf()
hardBtn = nil
impossibleBtn:removeSelf()
impossibleBtn = nil
end
-- Listener setup
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )
return scene