Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Multi Screen Menu Help

Author
Message
x_THOR_x
19
Years of Service
User Offline
Joined: 26th Feb 2007
Location:
Posted: 28th Nov 2011 22:32
I am trying to get a new menu to work. I got the backgrounds to load with the buttons. The problem I am having is when you click the START button on the first Menu the 2nd Menu shows but only if you hold the mouse in. If you let go of the mouse the 1st menu comes back up.

Also, once the 2nd menu loads I dont know how to disable the 2 buttons from the 1st menu (START - EXIT)

Any help would be great.

Menus Attached

Lucas Tiridath
AGK Developer
17
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 29th Nov 2011 22:18 Edited at: 29th Nov 2011 22:19
Hi there. The problems you are experiencing are because you are trying to have two menus in one main loop. One way to solve these issues would be to move your menus in to separate main loops. I usually use a structure that is something like this:



Note this code is untested!

If you want to have them in the same main loop for some reason, you'll want to have the drawing sections of your loop independent from the input handling. So you need to store in a variable which menu you are currently in and handle inputs and rendering accordingly. Because you are drawing your menus inside the click detection, only whilst a click is detected on the Start button is the other menu being drawn.

Now there are a few other issues with your code that you might like to consider. Generally you would not want to have your buttons drawn on to the menu background because this leads you to having to hard code coordinates for input detection which makes moving the buttons around very difficult. It can also cause scaling issues and limits the possibility of having animated buttons. Further you may want to consider using the png format for your images because bmps are huge and lack an alpha channel. You may also want to consider using sprites rather than pasting images but that is up to you.

Hope some of that helps. If it's still unclear on anything, do just say.

x_THOR_x
19
Years of Service
User Offline
Joined: 26th Feb 2007
Location:
Posted: 30th Nov 2011 00:48
I think I got it now, thank you for the help.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 3rd Dec 2011 09:53 Edited at: 3rd Dec 2011 09:55
What I would do, (And in fact have done in all my DBP and AppGameKit projects) is have a system where each screen is held in it's own typed array.

I use two typed arrays,

SCREEN, and UI.

SCREEN contains the values for how the screen looks.
UI contains each UI element. (Such as images, text, buttons etc)

Each UI element has a field for which screen it's a part of.

So you can have a variable, for example we'll call it CURRENTSCREEN and set it to screen 1.

CURRENTSCREEN = 1.

Now within your menu loop, only show UI's which are a part of that screen;

If UI( id ).Screen = CURRENTSCREEN
`Draw element here.
EndIf

That way, when you click a button which moves you to the next screen, you just change currentscreen to be whatever screen you want, and that screen will appear, within the same loop.

Simple as pie!


I use this very method and have a very robust, XML based, scriptable UI system which car create powerpoint style interfaces. All my games use this method of interfacing. Obviously, my system is a little more complex than that, as my screen have entry/exit transitions, alpha transparency levels which affect the UI element on them and other cool UI things.
If you want, I'll create a video of my UI's in use so you can see the kind of things I can do with it.

My signature is NOT a moderator plaything! Stop changing it!
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 3rd Dec 2011 09:56
Sorry for the double post, forgot to set mailback.

My signature is NOT a moderator plaything! Stop changing it!

Login to post a reply

Server time is: 2026-07-10 07:38:14
Your offset time is: 2026-07-10 07:38:14