Hello everyone!
I am using monarch for screen management and have trying to do transitions for more than an hour and half now
The documentation is not clear unfortunately, and the previously answered questions already were close to the answers, without specifying anything for people to use as a reference afterwards.
My scene is switched correctly but there are two problems:
- There is no transition, be it slide_in or fade_in
- There screen I switched to does not acquire focus
I do get DEBUG:SCRIPT: Message: hash: [transition_show_in]
which I think means that the transition started, but it never ends.
Here is the current hierarchy of my project:
Here are the current scripts:
-- intro.gui_script
local monarch = require("monarch.monarch")
local defork = require("defork.defork")
local current_node = 0
local function show_text()
defork.setCurrentNode(current_node)
local text_node = gui.get_node("text")
gui.set_text(text_node, defork.getText())
end
function init(self)
print("Intro screen init")
msg.post(".", "acquire_input_focus")
defork.load("/assets/story/intro.json")
current_node = defork.getStartNodeID()
show_text()
end
function on_input(self, action_id, action)
if action.pressed then
print("Key pressed")
local options = defork.getOptions(current_node)
if not options then
monarch.back()
msg.post("main:/controller#main_controller", "show_intro2")
end
current_node = options[1].pid
show_text()
end
end
-- fader.gui_script
local transitions = require "monarch.transitions.gui"
local monarch = require("monarch.monarch")
local transition
function init(self)
monarch.add_listener(".")
transition = transitions.create(gui.get_node("root"))
.show_in(transitions.slide_in_right, gui.EASING_OUTQUAD, 0.8, 0)
.show_out(transitions.slide_in_right, gui.EASING_INQUAD, 0.8, 0)
.back_in(transitions.slide_in_right, gui.EASING_OUTQUAD, 0.8, 0)
.back_out(transitions.slide_in_right, gui.EASING_INQUAD, 0.8, 0)
msg.post("#", "ready")
end
function on_message(self, message_id, message, sender)
print("Message: ", message_id)
if message_id == hash("show_first_screen") then
monarch.show("intro")
elseif message_id == hash("show_intro") then
monarch.show("intro")
elseif message_id == hash("show_intro2") then
elseif message_id == hash("ready") then
monarch.on_transition("intro", transition)
msg.post(".", "show_first_screen")
end
-- you can also check when a transition has completed:
if message_id == monarch.TRANSITION.DONE then
print("Show in done!")
end
end
-- main_controller.script
function init(self)
msg.post("@render:", "use_fixed_fit_projection", { near = -1, far = 1 })
msg.post("@render:", "clear_color", { color = vmath.vector4(1, 0, 0, 0) } )
end
Thank you in advance for your help