-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestart.lua
111 lines (82 loc) · 2.59 KB
/
restart.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
display.setStatusBar(display.HiddenStatusBar)
local storyboard = require ("storyboard")
local scene = storyboard.newScene()
system.activate( "multitouch" )
-- Variables to Determine Center of Screen
_W = display.contentWidth / 2;
_H = display.contentHeight / 2;
local mydata = require( "mydata" )
local mylevel = require( "mylevel" )
-- background
function restartGame(event)
if event.phase == "ended" then
storyboard.gotoScene("start")
end
end
function dat()
dat1= transition.to(levelText,{time=200, alpha=1})
dat2=transition.to(scoreText,{time=200, alpha=1})
end
function showStart()
startTransition = transition.to(restart,{time=200, alpha=1})
end
function showGameOver()
fadeTransition = transition.to(gameOver,{time=600, alpha=1,onComplete=showScore})
end
function scene:createScene(event)
local screenGroup = self.view
local background = display.newImage ("images/background.png"); -- Place background image
background.x = _W;
background.y = 150;
background.speed = 1;
screenGroup:insert(background);
gameOver = display.newImageRect("gameOver.png",500,100)
gameOver.x = _W
gameOver.y = _H-100
gameOver.alpha = 0
screenGroup:insert(gameOver)
restart = display.newImageRect("re3.png",200,110)
restart.x = _W+20;
restart.y =_H
restart.alpha = 0
screenGroup:insert(restart)
if mydata.score == nil then
mydata.score=0
end
scoreText = display.newText("Your Score:"..mydata.score,_W+20,
_H+70, native.systemFont, 36)
--scoreText:setFillColor(0,0,)
scoreText.alpha = 0
screenGroup:insert(scoreText)
if mylevel.level == nil then
mylevel.level=0
end
levelText = display.newText("Your Level:"..mylevel.level,_W+20,
_H+110, native.systemFont, 36)
--scoreText:setFillColor(0,0,)
levelText.alpha = 0
screenGroup:insert(levelText)
end
function scene:enterScene(event)
local screenGroup = self.view
local previous = storyboard.getPrevious()
if previous ~= "main" and previous then
storyboard.removeScene(previous)
end
restart:addEventListener("touch", restartGame)
showGameOver()
dat()
showStart()
end
function scene:exitScene(event)
local screenGroup = self.view
restart:removeEventListener("touch", restartGame)
end
function scene:destroyScene(event)
local screenGroup = self.view
end
scene:addEventListener("createScene", scene)
scene:addEventListener("enterScene", scene)
scene:addEventListener("exitScene", scene)
scene:addEventListener("destroyScene", scene)
return scene