Gui issue using Monarch transitions

Hi guys!
I am started to use monarch for switching scenes and it worked fine until I tried to add transitions.
After adding transition url, gui is started to act kinda weird.
It stops to redirect to the correct scene and gui is not removed as expected.

To switch scenes I use proxy collection with monarch.show(hash(“start”))
Code of transition is very simple:

function on_message(self, message_id, message, sender)
	print("GUI transition - message_id: " .. message_id)
	pprint(message)
	if message_id == hash("transition_show_in") then 
		msg.post(sender, monarch.TRANSITION.DONE)
	end
end

Cannot find where is the problem, can somebody advice something?

Hi. So the transition isn’t actually doing anything? I’m guessing that since it is instantaneous that this messes with monarch. You can try to add a timer before sending the transition done message just to verify.

Does not help, will continue to investigate.

I can take a look if you can share a zip with a repro case. Preferably in a GitHub issue or here.

Well I have found that there is missing monarch_screen_transition_out_finished.
Not sure why, but it does not send done message.

Proccess looks like this:

  1. monarch.show(‘start’) //preloaded
  2. DEBUG:SCRIPT: Transition: [transition_show_in]
  3. DEBUG:SCRIPT: Transition: [transition_done]
  4. monarch.show(‘next_scene’)
  5. DEBUG:SCRIPT: Transition: [transition_show_out]
  6. // should be transition_done, but missing it
  7. DEBUG:SCRIPT: Transition: [transition_show_in]
  8. DEBUG:SCRIPT: Transition: [transition_done]

Defined transitions:

function init(self)
	self.transition = transitions.create(gui.get_node("box"))
	.show_in(transitions.fade_out, gui.EASING_LINEAR, 2)
	.show_out(transitions.fade_in, gui.EASING_LINEAR, 2)
end

function on_message(self, message_id, message, sender)
	self.transition.handle(message_id, message, sender)
end

Seems it does not wait till transition finishes and moves to the next transition.

Ok. Can you create a minimal repro case and share it with me?

Uploaded: https://bitbucket.org/seqq86/monarch/src/master

Ok, so I took a look at your project. Some comments:

  • You have two screens, level1 and start.
  • Both screens use the same transition url /gui#transitions
  • The transition logic at /gui#transitions defines a transition for show_out and show_in
  • When you click you alternate between showing level1 and start

The problem is that when you show one screen it triggers the show_in transition and at the same time you hide the other screen which triggers the show_out transition. This means that the transition logic in /gui#transitions gets invoked twice and at the same time. Only one of these will finish.

The solution is to have the transition handler set up per screen. Meaning that level1 has one transition url and start has another. This way they won’t conflict like they do today.

Thank you for your time. But what if I plan to have 70+ scenes? If there is possibility to run transitions in sequance?

You could create a transition instance per screen at runtime:

local transitions = require "monarch.transitions.gui"
local monarch = require "monarch.monarch"

local function get_transition(self, screen)
	if not self.transitions[screen] then
		self.transitions[screen] = transitions.create(some_node)
			.show_in(transitions.fade_in, gui.EASING_OUTQUAD, 0.6, 0)
			.show_out(transitions.fade_out, gui.EASING_INQUAD, 0.6, 0)
	end
	return self.transitions[screen]
end

function init(self)
	self.transitions = {}
end

function on_message(self, message_id, message, sender)
	if message_id == monarch.TRANSITION.SHOW_IN or message_id == monarch.TRANSITION.SHOW_OUT then
		local transition = get_transition(self, message.screen)
		transition.handle(message_id, message, sender)
	end
end
2 Likes

Thank you for your answers!

Well… pretty strange transition_show_in does not sends screen in message.

Hmm, it should. What does message contain?

And used here:

And here:

I’m having the same issue that you described.

I have one scene and when I reload it (while that scene is loaded), the fade out transition does not work but only the fade in transition work.

Can you suggest any simple solution for this?

I would need to know more about the problem. Can you please create a ticket and also share a repro case so that I can test and see if it’s possible to create a fix:

Created the ticket and provided the repro case!

1 Like

Thank you. I will take a look later.