-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.lua
174 lines (147 loc) · 4.51 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
--1 = up, 2 = level, 3 = down
local birdPos = 1
local birdTitle
local incdec
local move = audio.loadSound("src/move.wav")
local btnPlay
local btnScore
counter = 0
dir = 2
function scene:createScene( event )
local group = self.view
storyboard.removeScene("hlp1")
gameNetwork.request("login",
{
userInitiated = false
})
display.setDefault( "magTextureFilter", "nearest" )
display.setDefault( "minTextureFilter", "nearest" )
ads.show( "banner", { x=0, y=0, appId=bannerAd } )
local bg = display.newImageRect("src/bg.png", display.contentWidth/2,display.contentHeight/2 )
bg.x = display.contentWidth/2
bg.y = display.contentHeight/2
bg:scale(2,2)
group:insert(bg)
local titleDrop = display.newText("SUPER CUBE", (display.contentWidth/2)+4, (display.contentHeight/4)+4, "04b", 32)
local title = display.newText("SUPER CUBE", display.contentWidth/2, display.contentHeight/4, "04b", 32)
titleDrop:setFillColor( black )
title:setFillColor(255/255, 245/255, 195/255)
group:insert(titleDrop)
group:insert(title)
birdTitle = display.newImage( "src/birdUp.png", display.contentWidth/2,display.contentHeight/2)
birdTitle:scale( 4, 4 )
birdTitle.y = (display.contentHeight/2)-40
group:insert(birdTitle)
btnPlay = display.newImage( "src/btnPlay.png", (display.contentWidth/2), (display.contentHeight/2)+130)
btnPlay:scale( 4, 4 )
group:insert(btnPlay)
btnScore = display.newImage( "src/pbScore.png", (display.contentWidth/2)+50,(display.contentHeight/2)+50)
btnScore:scale( 3, 3 )
group:insert(btnScore)
btnHelp = display.newImage("src/btnHelp.png",(display.contentWidth/2)-50,(display.contentHeight/2)+50)
btnHelp:scale(3,3)
group:insert(btnHelp)
end
local function updateBird(event)
local x = birdTitle.x
local y = birdTitle.y
if birdPos == 1 then
birdTitle:removeSelf()
birdTitle = nil
incdec = 1
birdTitle = display.newImage( "src/birdUp.png", display.contentWidth/2,display.contentHeight/2)
birdTitle:scale( 4, 4 )
birdTitle.y = y
birdTitle.x = x
birdPos = 2
elseif birdPos == 2 and incdec == 1 then
birdTitle:removeSelf()
birdTitle = nil
birdTitle = display.newImage( "src/birdMid.png", display.contentWidth/2,display.contentHeight/2)
birdTitle:scale( 4, 4 )
birdTitle.y = y
birdTitle.x = x
birdPos = 3
incdec = 0
elseif birdPos == 2 and incdec == 0 then
birdTitle:removeSelf()
birdTitle = nil
birdTitle = display.newImage( "src/birdMid.png", display.contentWidth/2,display.contentHeight/2)
birdTitle:scale( 4, 4 )
birdTitle.y = y
birdTitle.x = x
birdPos = 1
elseif birdPos == 3 then
birdTitle:removeSelf()
birdTitle = nil
birdTitle = display.newImage( "src/birdDown.png", display.contentWidth/2,display.contentHeight/2)
birdTitle:scale( 4, 4 )
birdTitle.y = y
birdTitle.x = x
birdPos = 2
incdec = 0
end
end
local function updatePos(event)
if counter ~= 5 then
birdTitle.y = birdTitle.y + dir
counter = counter + 1
else
counter = 0
dir = -dir
end
end
local function goToGame(event)
if event.phase == "ended" then
btnPlay.y = btnPlay.y - 3
audio.play(move)
timer.cancel( timer1 )
timer.cancel( timer2 )
storyboard.gotoScene("game", {effect = "crossFade", time = 500})
end
if event.phase == "began" then
btnPlay.y = btnPlay.y + 3
end
end
local function goToScore(event)
if event.phase == "ended" then
btnScore.y = btnScore.y - 3
audio.play(move)
timer.cancel( timer1 )
timer.cancel( timer2 )
storyboard.gotoScene("score", {effect = "crossFade", time = 500})
elseif event.phase == "began" then
btnScore.y = btnScore.y + 3
end
end
local function goToHelp(event)
if event.phase == "ended" then
btnHelp.y = btnHelp.y - 3
audio.play(move)
timer.cancel( timer1 )
timer.cancel( timer2 )
storyboard.gotoScene("hlp1", {effect = "crossFade", time = 500})
elseif event.phase == "began" then
btnHelp.y = btnHelp.y + 3
end
end
function scene:enterScene( event )
local group = self.view
storyboard.removeAll()
timer1 = timer.performWithDelay( 100, updateBird, 0 )
timer2 = timer.performWithDelay( 50, updatePos, 0 )
btnPlay:addEventListener( "touch", goToGame )
btnScore:addEventListener( "touch", goToScore )
btnHelp:addEventListener( "touch", goToHelp )
end
function scene:exitScene( event )
local group = self.view
group:insert(birdTitle)
audio.dispose()
end
scene:addEventListener( "createScene", scene )
scene:addEventListener( "enterScene", scene )
scene:addEventListener( "exitScene", scene )
return scene