Monarch - Simple screen manager


#1

I’ve had this screen manager library on my GitHub account for a while without sharing it. I was reluctant to share it since there already exists a couple of Defold screen managers and I didn’t feel Monarch was battle tested enough to go public with it. I have since then used it in a couple of projects and received some community feedback and pull requests and I feel that now is the time to announce it here. So here we go:

Monarch is a Defold screen manager with transition support and a straight forward API

Monarch screens are created in individual collections and loaded through collection proxies. The recommended setup is to create one game object per screen and per game object attach a collection proxy component and an instance of the screen.script provided by Monarch. The screen.script will take care of the setup of the screen.

The navigation in Monarch is based around a stack of screens. When a screen is shown it is pushed to the top of the stack. When going back to a previous screen the topmost screen on the stack is removed.

You show a screen by calling monarch.show(screen_id). You navigate back to a previous screen by calling monarch.back().

Monarch supports both normal screens and popups. It also supports a simple screen transitions system.

Learn more here: https://www.defold.com/community/projects/88415/


#2

Could I make the logo/ thumbnail for this if no one else will soon?

Monarch is great! I’ve been using it in several examples and commercial projects.


#3

My favorite Defold screen manager!
I use in several my projects!


#4

@Axel is doing one but why don’t you go ahead and create one as well and then we’ll put it to a vote? :slight_smile:


#5

I’m dropping this—@pkeod, go crazy! Great initiative :raised_hands:


#6

monarch_mini

Something like this?

Imp and Clipboard are still missing icons too… Imp could have a cute demon mascot, clipboard could have Clippy…

Attached zip

monarch_images.zip (493.7 KB)


#7

I like it! Thanks!


#8

Hold my beer

37


#9

Clipboard fixed, thanks for the great suggestion!


#10

Hi @britzl,
First of all, thanks for making this extension. It looks pretty easy to use but I have a quick question about structuring my game.

So I have a bunch of pages. (game, home, inventory, shop, etc.) Should I have one collection for each page and then have a game object with collection proxy and screen.script inside each collection? Or do I have one collection and a bunch of game objects for each page inside? (which seems to be what you have in the picture of your file structure on the assets page for Monarch) If I do that won’t game objects from all screens be shown at once?

Would you mind showing me the ideal way of structuring pages in Defold w. Monarch?
Thanks in advance.


#11

Tweetfighter is a good example of how to use Monarch. Tweetfighter has a bootstrap collection containing all of the screens, like this:

So it’s one game object per screen. Each game object contains a collection proxy pointing to a collection containing the screen and an instance of the screen.script (from Monarch).

The controller.script is the one launching the first Monarch screen:

And then navigation to more screens happen based on user input within the screens themselves:

PS The example project in the Monarch should show how to use Monarch and the different API functions.


#12

Thanks @britzl! This is working really well. :slight_smile: Monarch is really easy to work with! However, I do have a bit of a problem when I have a camera on one page (I’m using ross.grams’s wonderful Rendercam library) I’ve posted a question on the forum. Not sure if you’ve seen it yet. Here’s the question
Thanks again.


#13

It looks like you ran into a limitation of Rendercam that I haven’t gotten around to fixing yet, not a problem with Monarch. I answered in the other thread.