Scrolling Game Development Kit Forum

SGDK Version 2 => Help, Errors, FAQ => Topic started by: Vincent on 2009-04-15, 09:00:48 PM

Title: In game menu
Post by: Vincent on 2009-04-15, 09:00:48 PM
Hi guys, I got a question about in game menus.

I want to menu to be on a overlay map.  In fact, during the game, there is a status overlay map that displays HUD elements (life, magic, active skills, etc) and when the player presses ESC, the status overlay is replaced by the menu overlay.  And of course, they switch again when the player leavers the menu.  All of this works well. 

Here is the problem I am facing: in the menu, there are many pages.  The "main" page displays new game, load game, quit game and encyclopedia.  In the encyclopedia, there is a lot of info to show, learned skills, beaten enemies and the like.  I figured I would create a single map, named "menu" and put each page on a separate layer.  So is there a way at runtime to hide layers or make them completely invisible.  For the moment, there is a semitransparent base layer.  So the player can still see the game behind but it is still easy to read the menu, and on top of it, a lot of layers with text written in it (using the coolfont tileset).  I would need to hide all the text layers but the active one...  Is there a way to do this without changing the source code?

Thanks a lot! :)
Title: Re: In game menu
Post by: Jam0864 on 2009-04-16, 03:50:44 AM
Assign a value to the "modulatealpha" property, with 255 being opaque and 0 being transparent. (It can be modified at runtime)

That might only be for sprites though, haven't checked. If so you could just make the pages sprites.
Title: Re: In game menu
Post by: Vincent on 2009-04-16, 10:55:38 AM
Well, I figured that rather than making a lot of layers, I would make a lot of maps.  But I wonder, is there a way to copy-paste a map?  It would save me a lot of time!  I know the sgdk2 project file is an xml file, but I hesitate to duplicate a map in the project file...  Is it ok or is it dangerous to corrupt the project file?

Thanks :)
Title: Re: In game menu
Post by: durnurd on 2009-04-16, 11:08:48 AM
As always, back up the project before attempting to edit XML.  This is easier in SGDK2 because it's all in one file!

But you shouldn't (need to) create a bunch of different but similar maps.  Just set up a counter to detect which screen to display, and in a plan, check if the counter is different than the currently displayed screen, and change the content of the layer.  Without knowing how your overlay is set up, I can't give you much advice beyond that, but the general idea would be to have one layer (the furthest back) have a scroll rate of 0, which will then always be displayed.  This is the "container".  Then create other layers that have offsets in the map (so they don't have a bunch of empty space at the beginning) and scroll to the correct position when you want to change what's displaying.

Of course, I think the best option would be to write a custom code object to help you display what you need to, but if you aren't into writing code, this is sort of a hack workaround that'll do in a pinch.
Title: Re: In game menu
Post by: Jam0864 on 2009-04-16, 07:05:21 PM
Scrolling method works fine, but I think it would be easier to put all the screens on top of each other and change the opacity of each to show the one you want. :P
Title: Re: In game menu
Post by: Vincent on 2009-04-17, 07:04:45 AM
Thanks for your help guys! :)
Title: Re: In game menu
Post by: bluemonkmn on 2009-04-19, 08:41:10 AM
I don't know if I completely understood durnurd's suggestion, but I did get an idea from it (which maybe matches the intent).  Rather than creating multiple separate layers or maps to contain this content, you could just have one overlay layer that you use to display menus, and write some functions to update this layer as if it were a screen of text.  You can create a "PrintText" function, a "Locate" function, a "clear" function and so forth to output text, set the current position and reset the content of the layer.  On the plus side, you don't have to create a new layer every time you introduce a new menu screen, and all the menu behavior could maybe be maintained in one place.  On the negative side, though, you wouldn't be able to visually design how your menus look in a WYSIWYG editor, and easily add fancy decorations and such.  Positioning things correctly would be trial and error.  If you think your menus are going to be formatted in a relatively static way (not be constantly changing), and will include lots if formatting and decoration, you might want to go the route of designing them in the layer editor, but if you want the freedom to change, add and reformat the menus easily by editing the code, you might not want to lock down each menu's design in the layer editor.