Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Is there some smarter way to create a game menu, than this?  (Read 2543 times)

0 Members and 1 Guest are viewing this topic.

newn

  • Guest
Is there some smarter way to create a game menu, than this?
« on: August 24, 2010, 09:48:18 am »
Hi everyone. I thought of a way with lots IF statements. Is there any... smarter way to create a menu? Exit, options, that kind of stuff.

Finn

  • Jr. Member
  • **
  • Posts: 90
    • View Profile
Is there some smarter way to create a game menu, than this?
« Reply #1 on: August 24, 2010, 12:25:09 pm »
Well...I do it like this for each button:
Code: [Select]

if(MouseOver(Button))
{
    Button.SetImage(Img_Mouseover);//a Image that for example lightens
    if(Clicked(Button))
    {
        GameState = Next_GameState;
        break;
    }
}
else
    Button.SetImage(Img);//The normal button-image

newn

  • Guest
Is there some smarter way to create a game menu, than this?
« Reply #2 on: August 24, 2010, 12:39:49 pm »
Thanks, that sounds nice for a mouse. I wasn't thinking about mouse, to tell the truth. But yea, i'll implement this feature too.

What i was thinking, is buttons, but as i accidentally wrote in another thread, while talking to a few people (multitasking sucks sometimes), seems, like i got it the right way, if use the menu with keyboard keys.

Mindiell

  • Hero Member
  • *****
  • Posts: 1261
    • ICQ Messenger - 41484135
    • View Profile
Is there some smarter way to create a game menu, than this?
« Reply #3 on: August 24, 2010, 01:56:43 pm »
If you look at this tuto on the wiki, I did use a simple menu with up and down keys.
Mindiell
----

Spidyy

  • Sr. Member
  • ****
  • Posts: 493
    • View Profile
Is there some smarter way to create a game menu, than this?
« Reply #4 on: August 24, 2010, 07:17:25 pm »
I gave some source and a tutorial on the french wiki here : http://www.sfml-dev.org/wiki/fr/sources/abstract_menu

I'll work on a translation later, but you can try to use the code as it is presented.

In some word, you got 4 abstract class (and 3 utility ones) to create a menu structure that can respond to actions (up down left right use) and call for events. The Panel contains Widget that are parsed by a Cursor. The Widgets can call for WidgetEvents.

With this short technics, you can create menu like the one in the exemple screenshot. It don't respond to mouse click, but you can implement this though.

 

anything