Monarch did not stack the first screen (SOLVED)

Hi, I’m having a problem with Monarch, specifically is the stacking system. I’ve follow the doc, looking at the example, but for some reasons when I try to call the screen for the first time, it did not stack, so am I doing anything wrong, or it’s a bug?


image
The screen is there, but somehow the stacking system did not work. I’m using Defold version 1.3.0 and did not update yet.

Thank you!

The monarch.show() function you called just before print(monarch.get_stack()) incorporates coroutines according to the source: https://github.com/britzl/monarch/blob/master/monarch/monarch.lua

Monarch takes a frame or two to load a new screen. Therefore, your monarch.get_stack() function won’t show anything until at least a frame later. For example, try printing its contents in your script’s update() function. You’ll notice that the stack now shows your screen.

1 Like

Oh I see it now, but I also find another problem: when I use use monarch.show() to show other screen, it did not stack the second screen and instead, it unload the first screen and in the stack there is only second screen.


image

I want to stack the “in_game” screen on top of the “level_selected” screen so that I can go back using the monarch.back() function.

Can you help me with this issue please?

Thank you!!!

Correct. And if you have transitions it can take even longer. The fourth argument to monarch.show() is a callback function which will be called when the screen is fully visible:

That’s strange. I’m not sure what’s going on there to be honest. Do you have any errors in your console? You can get additional information about what Monarch is doing by enabling extra logging using monarch.debug():

If you are unable to figure out what is wrong then please open a ticket on GitHub and attach a small project where this problem happens.

1 Like

I just used the monarch.debug() but I’m not so sure what I’m looking at or how to read the debug console, but here it is:

This is the process of me transition from the “level” screen to “in_game” screen. Do you have any idea of what the issue is? Is it because of the version of defold version of I’m using? (It’s 1.3.0) Or is it might be other issues?

Thank you!!!

No, the version of Defold has nothing to do with this. Could you please create a support ticket here: https://github.com/britzl/monarch/issues/new

Please include a zip file with a small sample project where I can test this.

Loopformer.zip (2.6 MB)
This is the file contain the game, and I’ve created, and yes, I’ve post the issue that I’ve facing with on github. Can you check it out? And I want to apologize in advance as the code and the structure is kind of messy and spaghetti :sweat:, but I really want to find the solution to fix this issue. Thank you so much!!!

I took a quick look and you have set your “level” (the level select) screen as a popup. You can’t stack other screens on top of a popup (unless it is another popup and you have the “Popup on Popup” checkbox toggled).

Uncheck the “Popup” checkbox on that screen and you’re good!

OMG I WANT TO SAY THANK YOU SO SOOO MUCH!!!
Welp, it’s kinda dumb of me :rofl::rofl::rofl: but only this issue has driven me nut whole day already, and yet the solution to the problem is soooooooo simple. I’ve been smiling and laughing for 30 minutes already :rofl::rofl::rofl:
Anw, thank you so much and wish you have a great day :wink::smiling_face_with_three_hearts:

1 Like