3
0
mirror of https://github.com/britzl/monarch.git synced 2025-06-26 18:07:46 +02:00

Use new on_transition()

This commit is contained in:
Björn Ritzl 2023-08-02 07:47:47 +02:00
parent 0191a4e540
commit 4e13660d63
9 changed files with 24 additions and 52 deletions

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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