Skip to content

Commit 5901a0a

Browse files
committed
time is now on client shown
1 parent 68fe639 commit 5901a0a

File tree

3 files changed

+138
-0
lines changed

3 files changed

+138
-0
lines changed

Defold/scenes/main.collection

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,3 +1128,92 @@ embedded_instances {
11281128
z: 1.0
11291129
}
11301130
}
1131+
embedded_instances {
1132+
id: "timer"
1133+
data: "components {\n"
1134+
" id: \"timer\"\n"
1135+
" component: \"/scripts/timer.script\"\n"
1136+
" position {\n"
1137+
" x: 0.0\n"
1138+
" y: 0.0\n"
1139+
" z: 0.0\n"
1140+
" }\n"
1141+
" rotation {\n"
1142+
" x: 0.0\n"
1143+
" y: 0.0\n"
1144+
" z: 0.0\n"
1145+
" w: 1.0\n"
1146+
" }\n"
1147+
"}\n"
1148+
"embedded_components {\n"
1149+
" id: \"label\"\n"
1150+
" type: \"label\"\n"
1151+
" data: \"size {\\n"
1152+
" x: 148.0\\n"
1153+
" y: 64.0\\n"
1154+
" z: 0.0\\n"
1155+
" w: 0.0\\n"
1156+
"}\\n"
1157+
"scale {\\n"
1158+
" x: 1.0\\n"
1159+
" y: 1.0\\n"
1160+
" z: 1.0\\n"
1161+
" w: 0.0\\n"
1162+
"}\\n"
1163+
"color {\\n"
1164+
" x: 0.0\\n"
1165+
" y: 0.0\\n"
1166+
" z: 0.0\\n"
1167+
" w: 1.0\\n"
1168+
"}\\n"
1169+
"outline {\\n"
1170+
" x: 0.0\\n"
1171+
" y: 0.0\\n"
1172+
" z: 0.0\\n"
1173+
" w: 0.0\\n"
1174+
"}\\n"
1175+
"shadow {\\n"
1176+
" x: 0.34444445\\n"
1177+
" y: 0.34444445\\n"
1178+
" z: 0.34444445\\n"
1179+
" w: 0.43333334\\n"
1180+
"}\\n"
1181+
"leading: 1.0\\n"
1182+
"tracking: 0.0\\n"
1183+
"pivot: PIVOT_W\\n"
1184+
"blend_mode: BLEND_MODE_ALPHA\\n"
1185+
"line_break: true\\n"
1186+
"text: \\\"Score:\\\"\\n"
1187+
"font: \\\"/larger.font\\\"\\n"
1188+
"material: \\\"/builtins/fonts/label.material\\\"\\n"
1189+
"\"\n"
1190+
" position {\n"
1191+
" x: 0.0\n"
1192+
" y: 0.0\n"
1193+
" z: 0.0\n"
1194+
" }\n"
1195+
" rotation {\n"
1196+
" x: 0.0\n"
1197+
" y: 0.0\n"
1198+
" z: 0.0\n"
1199+
" w: 1.0\n"
1200+
" }\n"
1201+
"}\n"
1202+
""
1203+
position {
1204+
x: 850.0
1205+
y: 730.0
1206+
z: 0.1
1207+
}
1208+
rotation {
1209+
x: 0.0
1210+
y: 0.0
1211+
z: 0.0
1212+
w: 1.0
1213+
}
1214+
scale3 {
1215+
x: 1.0
1216+
y: 1.0
1217+
z: 1.0
1218+
}
1219+
}

Defold/scripts/game_controller.script

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ function drawScore(change)
6565
if v['field'] == 'score' then
6666
msg.post('/score', 'score', {score = v['value']})
6767
end
68+
69+
if v['field'] == 'time' then
70+
msg.post('/timer', 'timer', {timer = v['value']})
71+
end
72+
6873
end
6974
end
7075

Defold/scripts/timer.script

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
function init(self)
2+
-- Add initialization code here
3+
-- Learn more: https://defold.com/manuals/script/
4+
-- Remove this function if not needed
5+
end
6+
7+
function final(self)
8+
-- Add finalization code here
9+
-- Learn more: https://defold.com/manuals/script/
10+
-- Remove this function if not needed
11+
end
12+
13+
function update(self, dt)
14+
-- Add update code here
15+
-- Learn more: https://defold.com/manuals/script/
16+
-- Remove this function if not needed
17+
end
18+
19+
function on_message(self, message_id, message, sender)
20+
-- Add message-handling code here
21+
-- Learn more: https://defold.com/manuals/message-passing/
22+
-- Remove this function if not needed
23+
if message.timer then
24+
label.set_text('#label', 'Time: '.. message.timer)
25+
end
26+
end
27+
28+
function on_input(self, action_id, action)
29+
-- Add input-handling code here. The game object this script is attached to
30+
-- must have acquired input focus:
31+
--
32+
-- msg.post(".", "acquire_input_focus")
33+
--
34+
-- All mapped input bindings will be received. Mouse and touch input will
35+
-- be received regardless of where on the screen it happened.
36+
-- Learn more: https://defold.com/manuals/input/
37+
-- Remove this function if not needed
38+
end
39+
40+
function on_reload(self)
41+
-- Add reload-handling code here
42+
-- Learn more: https://defold.com/manuals/hot-reload/
43+
-- Remove this function if not needed
44+
end

0 commit comments

Comments
 (0)