-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathretry.lua
executable file
·49 lines (34 loc) · 1.34 KB
/
retry.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
local composer = require("composer")
local scene = composer.newScene()
local widget = require("widget")
local m = require("lib.mydata")
local screenW, screenH, halfW = display.contentWidth, display.contentHeight, display.contentWidth*0.5
function scene:show(event)
local sceneGroup = self.view
local phase = event.phase
if (phase == "will") then
elseif (phase == "did") then
composer.removeScene("game")
end
end
function scene:create(event)
local sceneGroup = self.view
local function restart()
composer.removeScene("retry")
composer.gotoScene("game", {effect="fade", time=200})
end
local yourScore = display.newText({text='Your Score: ' .. m.score, width=screenW, height=40, x=0, y=screenH/2-90, align="center"})
yourScore.anchorX, yourScore.anchorY = 0,0
sceneGroup:insert(yourScore)
local bestScore = display.newText({text='Best Score: ' .. m.getBestScore(), width=screenW, height=40, x=0, y=screenH/2-60, align="center"})
bestScore.anchorX, bestScore.anchorY = 0,0
sceneGroup:insert(bestScore)
local restartBtn = widget.newButton({label="Restart", fontSize=50, x=screenW/2, y=screenH/2 + 30, onPress=restart})
sceneGroup:insert(restartBtn)
end
function scene:destroy(event)
end
scene:addEventListener("create", scene)
scene:addEventListener("show", scene)
scene:addEventListener("destroy", scene)
return scene