message `monarch.TRANSITION.DONE` not triggered
baochungit opened this issue ยท 4 comments
baochungit commented
Hi, I've just checked a custom transition by the following code but it seems SHOW_IN not be done or missing the message
local transitions = require "monarch.transitions.gui"
local monarch = require "monarch.monarch"
function init(self)
local transition = transitions.create(gui.get_node("root"))
.show_in(transitions.slide_in_right, gui.EASING_OUTQUAD, 0.6, 0)
.show_out(transitions.slide_out_left, gui.EASING_INQUAD, 0.6, 0)
.back_in(transitions.slide_in_left, gui.EASING_OUTQUAD, 0.6, 0)
.back_out(transitions.slide_out_right, gui.EASING_INQUAD, 0.6, 0)
monarch.on_transition("foobar", transition)
end
function on_message(self, message_id, message, sender)
monarch.on_message(message_id, message, sender)
-- you can also check when a transition has completed:
if message_id == monarch.TRANSITION.DONE and message.transition == monarch.TRANSITION.SHOW_IN then
print("Show in done!")
end
end
britzl commented
And you are calling monarch.show("foobar")
somewhere?
baochungit commented
Yes, from another screen. Another thing I realised that when I call monarch.hide("foobar")
, it seems
.back_out(...)
works (has animation) while I expect .show_out(...)
will do animation.
britzl commented
Ah, yes, I see now. The documentation and code doesn't match. I think I can add support at least for sending a transition done message when a screen is shown.
britzl commented
Or actually, I think it is better to use monarch.add_listener()
function init(self)
monarch.add_listener()
end
function on_message(self, message_id, message, sender)
...
if message_id == monarch.SCREEN_TRANSITION_IN_FINISHED and message.screen == hash("window1") then
print("Window1 is now shown")
end
end