Skip to content

Commit 4e13660

Browse files
committed
Use new on_transition()
1 parent 0191a4e commit 4e13660

9 files changed

Lines changed: 24 additions & 52 deletions

File tree

example/advanced/about.gui_script

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ function init(self)
55
msg.post(".", "acquire_input_focus")
66
gui.set_render_order(15)
77

8-
self.transition = transitions.create(gui.get_node("root"))
8+
local transition = transitions.create(gui.get_node("root"))
99
.show_in(transitions.slide_in_top, gui.EASING_OUTQUAD, 0.6, 0)
1010
.show_out(transitions.slide_out_top, gui.EASING_INQUAD, 0.6, 0)
1111
.back_in(transitions.slide_in_top, gui.EASING_OUTQUAD, 0.6, 0)
1212
.back_out(transitions.slide_out_top, gui.EASING_INQUAD, 0.6, 0)
13+
14+
monarch.on_transition("about", transition)
1315
end
1416

1517
function on_input(self, action_id, action)
@@ -27,5 +29,5 @@ function on_input(self, action_id, action)
2729
end
2830

2931
function on_message(self, message_id, message, sender)
30-
self.transition.handle(message_id, message, sender)
32+
monarch.on_message(message_id, message, sender)
3133
end

example/advanced/advanced.collection

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@ embedded_instances {
2121
" value: \"menu\"\n"
2222
" type: PROPERTY_TYPE_HASH\n"
2323
" }\n"
24-
" properties {\n"
25-
" id: \"transition_id\"\n"
26-
" value: \"/go\"\n"
27-
" type: PROPERTY_TYPE_HASH\n"
28-
" }\n"
29-
" properties {\n"
30-
" id: \"focus_id\"\n"
31-
" value: \"/go\"\n"
32-
" type: PROPERTY_TYPE_HASH\n"
33-
" }\n"
3424
" property_decls {\n"
3525
" }\n"
3626
"}\n"
@@ -146,11 +136,6 @@ embedded_instances {
146136
" value: \"pregame\"\n"
147137
" type: PROPERTY_TYPE_HASH\n"
148138
" }\n"
149-
" properties {\n"
150-
" id: \"transition_url\"\n"
151-
" value: \"pregame:/go#pregame\"\n"
152-
" type: PROPERTY_TYPE_URL\n"
153-
" }\n"
154139
" property_decls {\n"
155140
" }\n"
156141
"}\n"
@@ -211,11 +196,6 @@ embedded_instances {
211196
" value: \"game\"\n"
212197
" type: PROPERTY_TYPE_HASH\n"
213198
" }\n"
214-
" properties {\n"
215-
" id: \"transition_url\"\n"
216-
" value: \"game:/go#game\"\n"
217-
" type: PROPERTY_TYPE_URL\n"
218-
" }\n"
219199
" property_decls {\n"
220200
" }\n"
221201
"}\n"
@@ -287,16 +267,6 @@ embedded_instances {
287267
" type: PROPERTY_TYPE_BOOLEAN\n"
288268
" }\n"
289269
" properties {\n"
290-
" id: \"transition_url\"\n"
291-
" value: \"about:/go#about\"\n"
292-
" type: PROPERTY_TYPE_URL\n"
293-
" }\n"
294-
" properties {\n"
295-
" id: \"focus_url\"\n"
296-
" value: \"about:/go#about\"\n"
297-
" type: PROPERTY_TYPE_URL\n"
298-
" }\n"
299-
" properties {\n"
300270
" id: \"preload\"\n"
301271
" value: \"true\"\n"
302272
" type: PROPERTY_TYPE_BOOLEAN\n"
@@ -376,11 +346,6 @@ embedded_instances {
376346
" value: \"true\"\n"
377347
" type: PROPERTY_TYPE_BOOLEAN\n"
378348
" }\n"
379-
" properties {\n"
380-
" id: \"transition_url\"\n"
381-
" value: \"confirm:/go#confirm\"\n"
382-
" type: PROPERTY_TYPE_URL\n"
383-
" }\n"
384349
" property_decls {\n"
385350
" }\n"
386351
"}\n"

example/advanced/confirm.gui_script

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ function init(self)
77
self.no = gui.get_node("no_button")
88
gui.set_render_order(15)
99

10-
self.transition = transitions.create(gui.get_node("root"))
10+
local transition = transitions.create(gui.get_node("root"))
1111
.show_in(transitions.scale_in, gui.EASING_OUTBACK, 0.3, 0)
1212
.show_out(transitions.scale_out, gui.EASING_INBACK, 0.3, 0)
1313
.back_in(transitions.scale_in, gui.EASING_OUTBACK, 0.3, 0)
1414
.back_out(transitions.scale_out, gui.EASING_INBACK, 0.3, 0)
15+
16+
monarch.on_transition("confirm", transition)
1517
end
1618

1719
function on_input(self, action_id, action)
@@ -35,5 +37,5 @@ function on_input(self, action_id, action)
3537
end
3638

3739
function on_message(self, message_id, message, sender)
38-
self.transition.handle(message_id, message, sender)
40+
monarch.on_message(message_id, message, sender)
3941
end

example/advanced/game.gui_script

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ local transitions = require "monarch.transitions.gui"
33

44
function init(self)
55
msg.post(".", "acquire_input_focus")
6-
6+
77
local data = monarch.data(hash("game"))
88
gui.set_text(gui.get_node("level"), tostring(data.level))
99

10-
self.transition = transitions.in_right_out_left(gui.get_node("root"), 0.6, 0)
10+
local transition = transitions.in_right_out_left(gui.get_node("root"), 0.6, 0)
11+
monarch.on_transition("game", transition)
1112
end
1213

1314
function on_input(self, action_id, action)
@@ -21,5 +22,5 @@ function on_input(self, action_id, action)
2122
end
2223

2324
function on_message(self, message_id, message, sender)
24-
self.transition.handle(message_id, message, sender)
25+
monarch.on_message(message_id, message, sender)
2526
end

example/advanced/menu.gui_script

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ function init(self)
88

99
gui.animate(gui.get_node("spinner"), gui.PROP_ROTATION, vmath.vector3(0, 0, -360), gui.EASING_INOUTQUAD, 2, 0, nil, gui.PLAYBACK_LOOP_FORWARD)
1010

11-
self.transition = transitions.fade_in_out(gui.get_node("root"), 0.6, 0)
11+
local transition = transitions.fade_in_out(gui.get_node("root"), 0.6, 0)
12+
monarch.on_transition("menu", transition)
1213
end
1314

1415
function on_input(self, action_id, action)
@@ -28,7 +29,7 @@ function on_input(self, action_id, action)
2829
end
2930

3031
function on_message(self, message_id, message, sender)
31-
self.transition.handle(message_id, message, sender)
32+
monarch.on_message(message_id, message, sender)
3233
if message_id == monarch.FOCUS.GAINED then
3334
gui.set_text(gui.get_node("timestamp"), os.date())
3435
end

example/advanced/popup.gui_script

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ function init(self)
99
gui.set_render_order(14)
1010

1111
gui.animate(gui.get_node("spinner"), gui.PROP_ROTATION, vmath.vector3(0, 0, -360), gui.EASING_INOUTQUAD, 2, 0, nil, gui.PLAYBACK_LOOP_FORWARD)
12-
13-
self.transition = transitions.create(gui.get_node("root"))
12+
13+
local transition = transitions.create(gui.get_node("root"))
1414
.show_in(transitions.scale_in, gui.EASING_OUTBACK, 0.3, 0)
1515
.show_out(transitions.scale_out, gui.EASING_INBACK, 0.3, 0)
1616
.back_in(transitions.scale_in, gui.EASING_OUTBACK, 0.3, 0)
1717
.back_out(transitions.scale_out, gui.EASING_INBACK, 0.3, 0)
18+
monarch.on_transition("popup", transition)
1819
end
1920

2021
function on_input(self, action_id, action)
@@ -39,5 +40,5 @@ function on_input(self, action_id, action)
3940
end
4041

4142
function on_message(self, message_id, message, sender)
42-
self.transition.handle(message_id, message, sender)
43+
monarch.on_message(message_id, message, sender)
4344
end

example/advanced/pregame.gui_script

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ function init(self)
55
msg.post(".", "acquire_input_focus")
66
self.play = gui.get_node("play_button")
77
self.back = gui.get_node("back_button")
8-
9-
self.transition = transitions.in_right_out_left(gui.get_node("root"), 0.6, 0)
8+
9+
local transition = transitions.in_right_out_left(gui.get_node("root"), 0.6, 0)
10+
monarch.on_transition("pregame", transition)
1011
end
1112

1213
function on_input(self, action_id, action)
@@ -26,5 +27,5 @@ function on_input(self, action_id, action)
2627
end
2728

2829
function on_message(self, message_id, message, sender)
29-
self.transition.handle(message_id, message, sender)
30+
monarch.on_message(message_id, message, sender)
3031
end

example/slidingwindow/window2.gui_script

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,5 @@ function on_input(self, action_id, action)
2323
end
2424

2525
function on_message(self, message_id, message, sender)
26-
print("window2", message_id, message, sender)
2726
monarch.on_message(message_id, message, sender)
2827
end

game.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ dependencies#0 = https://github.com/britzl/deftest/archive/2.7.0.zip
55
dependencies#1 = https://github.com/defold/lua-language-server/releases/download/v0.0.3/release.zip
66

77
[bootstrap]
8-
main_collection = /example/slidingwindow/slidingwindow.collectionc
8+
main_collection = /example/advanced/advanced.collectionc
99

1010
[input]
1111
game_binding = /input/game.input_bindingc

0 commit comments

Comments
 (0)