-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinishLevel.lua
More file actions
156 lines (125 loc) · 4.32 KB
/
Copy pathfinishLevel.lua
File metadata and controls
156 lines (125 loc) · 4.32 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
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
local composer = require( "composer" )
local scene = composer.newScene()
local widget = require( "widget" )
-- Require "global" data table (https://coronalabs.com/blog/2013/05/28/tutorial-goodbye-globals/)
-- This will contain relevant data like the current level, max levels, number of stars earned, etc.
local myData = require( "mydata" )
local userScore = require( "_controls.levels-score-manager" )
local tracker = require("_externalModules.googleAnalitcs")
local userLib = require("lib.bussiness.user");
local levelAction = require("lib.bussiness.levelsAction")
local screenW, screenH, halfW = display.contentWidth, display.contentHeight, display.contentWidth*0.5
local sceneGroup = nil
function resetLevel()
composer.removeScene( "finishLevel", false )
composer.gotoScene( "level1", { effect="crossFade", time=500 } )
end
function nextLevel()
composer.removeScene( "finishLevel", false )
userScore.currentLevel=userScore.currentLevel + 1
composer.gotoScene( "level1", { effect="crossFade", time=500 } )
end
function scene:create (event)
tracker.EnterScene("Finish Level");
local params = event.params
local user = userLib.getUser();
local sceneGroup = self.view
local o = display.newRect( 0, 0, display.contentWidth / 2, display.contentHeight )
o.anchorX = 0
o.anchorY = 0
o.x = (display.contentWidth / 2) - (o.width /2)
o.y = 0
o:setFillColor( 0.7 )
local message = display.newText(1, 0, 0, native.systemFontBold, 40 )
message.anchorX = 0
message.anchorY = 0
message.text =params.message
message.x = (screenW /2) - message.width /2
message.y = (screenH/2) - 200
message:setTextColor(0,0,255)
local scoreLabel = display.newText( "Your Score", 0, 0, native.systemFontBold, 35 )
scoreLabel.anchorX = 0
scoreLabel.anchorY = 0
scoreLabel.x = (screenW /2) - scoreLabel.width /2
scoreLabel.y = (screenH/2) - 100
scoreLabel:setTextColor( 0, 0, 0, 255 )
local score = display.newText( params.total.." stars : "..params.stars.."/3", 0, 0, native.systemFont, 30 )
score.anchorX = 0
score.anchorY = 0
score.x = (screenW /2) - score.width /2
score.y = (screenH/2) - 50
score:setTextColor( 0, 0, 0, 255 )
local recordLabel = display.newText( "Your Best", 0, 0, native.systemFontBold, 35 )
recordLabel.anchorX = 0
recordLabel.anchorY = 0
recordLabel.x = (screenW /2) - recordLabel.width /2
recordLabel.y = (screenH/2)
recordLabel:setTextColor( 0, 0, 0, 255 )
-- local best = tostring(user.data.gameProgression.levels[params.currentType].data[params.currentLevel].bestTime)
local record = display.newText( "nil", 0, 0, native.systemFont, 30 )
record.anchorX = 0
record.anchorY = 0
record.x = (screenW /2) - record.width /2
record.y = (screenH/2) +50
record:setTextColor( 0, 0, 0, 255 )
local next= widget.newButton
{
id = "button1",
width = 100,
height = 100,
defaultFile = "assets/images/next_level.png",
overFile = "assets/images/next_level.png",
label = "",
onEvent = nextLevel
}
next.x = (screenW / 2) + 100
next.y = (screenH / 2) + 200
local reset= widget.newButton
{
id = "button1",
width = 100,
height = 100,
defaultFile = "assets/images/reset.png",
overFile = "assets/images/reset.png",
label = "",
onEvent = resetLevel
}
reset.x = (screenW / 2)
reset.y = (screenH / 2) + 200
sceneGroup:insert(o)
sceneGroup:insert(message)
sceneGroup:insert(scoreLabel)
sceneGroup:insert(score)
sceneGroup:insert(recordLabel)
sceneGroup:insert(record)
sceneGroup:insert(next)
sceneGroup:insert(reset)
end
-- On scene show...
function scene:show( event )
local sceneGroup = self.view
if ( event.phase == "did" ) then
end
end
-- On scene hide...
function scene:hide( event )
local sceneGroup = self.view
if ( event.phase == "will" ) then
-- sceneGroup:removeSelf()
end
end
-- On scene destroy...
function scene:destroy( event )
local sceneGroup = self.view
for i = 1, sceneGroup.numChildren do
sceneGroup[1]:removeSelf()
end
sceneGroup:removeSelf();
sceneGroup = nil
end
-- Composer scene listeners
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )
return scene