-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscreen2.lua
More file actions
108 lines (76 loc) · 2.12 KB
/
screen2.lua
File metadata and controls
108 lines (76 loc) · 2.12 KB
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
module(..., package.seeall)
--====================================================================--
-- SCENE: SCREEN 2
--====================================================================--
--[[
- Version: 1.3
- Made by Ricardo Rauber Pereira @ 2010
- Blog: http://rauberlabs.blogspot.com/
- Mail: ricardorauber@gmail.com
******************
- INFORMATION
******************
- Sample scene.
--]]
new = function ( params )
------------------
-- Groups
------------------
local localGroup = display.newGroup()
local params = {
level=1
score = 0
}
------------------
-- Display Objects
------------------
local easy = display.newText("Easy",0,0,nil,30)
easy.x = display.contentWidth/2
easy.y = display.contentHeight/6
local medium = display.newText("Medium",0,0,nil,30)
medium.x = display.contentWidth/2
medium.y = 2*display.contentHeight/6
local hard = display.newText("Hard",0,0,nil,30)
hard.x = display.contentWidth/2
hard.y = 3*display.contentHeight/6
------------------
-- Listeners
------------------
local easyTouched = function ( event )
params.level = 1
director:changeScene(params, "level1", "crossfade")
end
local medTouched = function ( event )
params.level = 2
director:changeScene(params, "level1", "crossfade")
end
local hardTouched = function ( event )
params.level = 4
director:changeScene(params, "level1", "crossfade")
end
--====================================================================--
-- INITIALIZE
--====================================================================--
local initVars = function ()
------------------
-- Inserts
------------------
localGroup:insert( easy )
localGroup:insert( medium )
localGroup:insert( hard )
------------------
-- Listeners
------------------
easy:addEventListener( "touch" , easyTouched )
medium:addEventListener( "touch" , medTouched )
hard:addEventListener( "touch" , hardTouched )
end
------------------
-- Initiate variables
------------------
initVars()
------------------
-- MUST return a display.newGroup()
------------------
return localGroup
end