diff --git a/example/advanced/about.gui_script b/example/advanced/about.gui_script index 394d4ee..9c7a0a9 100644 --- a/example/advanced/about.gui_script +++ b/example/advanced/about.gui_script @@ -5,11 +5,13 @@ function init(self) msg.post(".", "acquire_input_focus") gui.set_render_order(15) - self.transition = transitions.create(gui.get_node("root")) + local transition = transitions.create(gui.get_node("root")) .show_in(transitions.slide_in_top, gui.EASING_OUTQUAD, 0.6, 0) .show_out(transitions.slide_out_top, gui.EASING_INQUAD, 0.6, 0) .back_in(transitions.slide_in_top, gui.EASING_OUTQUAD, 0.6, 0) .back_out(transitions.slide_out_top, gui.EASING_INQUAD, 0.6, 0) + + monarch.on_transition("about", transition) end function on_input(self, action_id, action) @@ -27,5 +29,5 @@ function on_input(self, action_id, action) end function on_message(self, message_id, message, sender) - self.transition.handle(message_id, message, sender) + monarch.on_message(message_id, message, sender) end diff --git a/example/advanced/advanced.collection b/example/advanced/advanced.collection index 0ef1890..5c55580 100644 --- a/example/advanced/advanced.collection +++ b/example/advanced/advanced.collection @@ -21,16 +21,6 @@ embedded_instances { " value: \"menu\"\n" " type: PROPERTY_TYPE_HASH\n" " }\n" - " properties {\n" - " id: \"transition_id\"\n" - " value: \"/go\"\n" - " type: PROPERTY_TYPE_HASH\n" - " }\n" - " properties {\n" - " id: \"focus_id\"\n" - " value: \"/go\"\n" - " type: PROPERTY_TYPE_HASH\n" - " }\n" " property_decls {\n" " }\n" "}\n" @@ -146,11 +136,6 @@ embedded_instances { " value: \"pregame\"\n" " type: PROPERTY_TYPE_HASH\n" " }\n" - " properties {\n" - " id: \"transition_url\"\n" - " value: \"pregame:/go#pregame\"\n" - " type: PROPERTY_TYPE_URL\n" - " }\n" " property_decls {\n" " }\n" "}\n" @@ -211,11 +196,6 @@ embedded_instances { " value: \"game\"\n" " type: PROPERTY_TYPE_HASH\n" " }\n" - " properties {\n" - " id: \"transition_url\"\n" - " value: \"game:/go#game\"\n" - " type: PROPERTY_TYPE_URL\n" - " }\n" " property_decls {\n" " }\n" "}\n" @@ -287,16 +267,6 @@ embedded_instances { " type: PROPERTY_TYPE_BOOLEAN\n" " }\n" " properties {\n" - " id: \"transition_url\"\n" - " value: \"about:/go#about\"\n" - " type: PROPERTY_TYPE_URL\n" - " }\n" - " properties {\n" - " id: \"focus_url\"\n" - " value: \"about:/go#about\"\n" - " type: PROPERTY_TYPE_URL\n" - " }\n" - " properties {\n" " id: \"preload\"\n" " value: \"true\"\n" " type: PROPERTY_TYPE_BOOLEAN\n" @@ -376,11 +346,6 @@ embedded_instances { " value: \"true\"\n" " type: PROPERTY_TYPE_BOOLEAN\n" " }\n" - " properties {\n" - " id: \"transition_url\"\n" - " value: \"confirm:/go#confirm\"\n" - " type: PROPERTY_TYPE_URL\n" - " }\n" " property_decls {\n" " }\n" "}\n" diff --git a/example/advanced/confirm.gui_script b/example/advanced/confirm.gui_script index 431ede1..6505af5 100644 --- a/example/advanced/confirm.gui_script +++ b/example/advanced/confirm.gui_script @@ -7,11 +7,13 @@ function init(self) self.no = gui.get_node("no_button") gui.set_render_order(15) - self.transition = transitions.create(gui.get_node("root")) + local transition = transitions.create(gui.get_node("root")) .show_in(transitions.scale_in, gui.EASING_OUTBACK, 0.3, 0) .show_out(transitions.scale_out, gui.EASING_INBACK, 0.3, 0) .back_in(transitions.scale_in, gui.EASING_OUTBACK, 0.3, 0) .back_out(transitions.scale_out, gui.EASING_INBACK, 0.3, 0) + + monarch.on_transition("confirm", transition) end function on_input(self, action_id, action) @@ -35,5 +37,5 @@ function on_input(self, action_id, action) end function on_message(self, message_id, message, sender) - self.transition.handle(message_id, message, sender) + monarch.on_message(message_id, message, sender) end diff --git a/example/advanced/game.gui_script b/example/advanced/game.gui_script index 765ae13..1564d20 100644 --- a/example/advanced/game.gui_script +++ b/example/advanced/game.gui_script @@ -3,11 +3,12 @@ local transitions = require "monarch.transitions.gui" function init(self) msg.post(".", "acquire_input_focus") - + local data = monarch.data(hash("game")) gui.set_text(gui.get_node("level"), tostring(data.level)) - self.transition = transitions.in_right_out_left(gui.get_node("root"), 0.6, 0) + local transition = transitions.in_right_out_left(gui.get_node("root"), 0.6, 0) + monarch.on_transition("game", transition) end function on_input(self, action_id, action) @@ -21,5 +22,5 @@ function on_input(self, action_id, action) end function on_message(self, message_id, message, sender) - self.transition.handle(message_id, message, sender) + monarch.on_message(message_id, message, sender) end diff --git a/example/advanced/menu.gui_script b/example/advanced/menu.gui_script index 17791f6..0f1d9fc 100644 --- a/example/advanced/menu.gui_script +++ b/example/advanced/menu.gui_script @@ -8,7 +8,8 @@ function init(self) gui.animate(gui.get_node("spinner"), gui.PROP_ROTATION, vmath.vector3(0, 0, -360), gui.EASING_INOUTQUAD, 2, 0, nil, gui.PLAYBACK_LOOP_FORWARD) - self.transition = transitions.fade_in_out(gui.get_node("root"), 0.6, 0) + local transition = transitions.fade_in_out(gui.get_node("root"), 0.6, 0) + monarch.on_transition("menu", transition) end function on_input(self, action_id, action) @@ -28,7 +29,7 @@ function on_input(self, action_id, action) end function on_message(self, message_id, message, sender) - self.transition.handle(message_id, message, sender) + monarch.on_message(message_id, message, sender) if message_id == monarch.FOCUS.GAINED then gui.set_text(gui.get_node("timestamp"), os.date()) end diff --git a/example/advanced/popup.gui_script b/example/advanced/popup.gui_script index 47301d3..d60100d 100644 --- a/example/advanced/popup.gui_script +++ b/example/advanced/popup.gui_script @@ -9,12 +9,13 @@ function init(self) gui.set_render_order(14) gui.animate(gui.get_node("spinner"), gui.PROP_ROTATION, vmath.vector3(0, 0, -360), gui.EASING_INOUTQUAD, 2, 0, nil, gui.PLAYBACK_LOOP_FORWARD) - - self.transition = transitions.create(gui.get_node("root")) + + local transition = transitions.create(gui.get_node("root")) .show_in(transitions.scale_in, gui.EASING_OUTBACK, 0.3, 0) .show_out(transitions.scale_out, gui.EASING_INBACK, 0.3, 0) .back_in(transitions.scale_in, gui.EASING_OUTBACK, 0.3, 0) .back_out(transitions.scale_out, gui.EASING_INBACK, 0.3, 0) + monarch.on_transition("popup", transition) end function on_input(self, action_id, action) @@ -39,5 +40,5 @@ function on_input(self, action_id, action) end function on_message(self, message_id, message, sender) - self.transition.handle(message_id, message, sender) + monarch.on_message(message_id, message, sender) end diff --git a/example/advanced/pregame.gui_script b/example/advanced/pregame.gui_script index b2c529b..695d3e5 100644 --- a/example/advanced/pregame.gui_script +++ b/example/advanced/pregame.gui_script @@ -5,8 +5,9 @@ function init(self) msg.post(".", "acquire_input_focus") self.play = gui.get_node("play_button") self.back = gui.get_node("back_button") - - self.transition = transitions.in_right_out_left(gui.get_node("root"), 0.6, 0) + + local transition = transitions.in_right_out_left(gui.get_node("root"), 0.6, 0) + monarch.on_transition("pregame", transition) end function on_input(self, action_id, action) @@ -26,5 +27,5 @@ function on_input(self, action_id, action) end function on_message(self, message_id, message, sender) - self.transition.handle(message_id, message, sender) + monarch.on_message(message_id, message, sender) end diff --git a/example/slidingwindow/window2.gui_script b/example/slidingwindow/window2.gui_script index 15bd842..2a395bf 100644 --- a/example/slidingwindow/window2.gui_script +++ b/example/slidingwindow/window2.gui_script @@ -23,6 +23,5 @@ function on_input(self, action_id, action) end function on_message(self, message_id, message, sender) - print("window2", message_id, message, sender) monarch.on_message(message_id, message, sender) end \ No newline at end of file diff --git a/game.project b/game.project index 00bc680..ec67d3a 100644 --- a/game.project +++ b/game.project @@ -5,7 +5,7 @@ dependencies#0 = https://github.com/britzl/deftest/archive/2.7.0.zip dependencies#1 = https://github.com/defold/lua-language-server/releases/download/v0.0.3/release.zip [bootstrap] -main_collection = /example/slidingwindow/slidingwindow.collectionc +main_collection = /example/advanced/advanced.collectionc [input] game_binding = /input/game.input_bindingc