Jump to content
  • Advertisement
Sign in to follow this  
Meerul264

SFML - How to create a main menu?

This topic is 1988 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

My question is quite straight forward. How to I create a main menu?

 

I suspect it is coded in the event loop. I want to test making a main menu by clicking on a button of the main menu, to start another loop (like starting the game for an example).

 

Thanks

Share this post


Link to post
Share on other sites
Advertisement

Well, there are multiple ways of doing it.  The crude way would be to show a picture, and when in that menu mode, check for mouse clicks within certain X/Y locations for "button presses".

 

A more elegant way would be to create Button classes that give you notifications on being pressed and have the abililty to be drawn.

 

An even better method might be to use previously created UI methods developed for SFML.  Check out the SFML Project forum at sfml-dev.org and look for different GUI's there.

Share this post


Link to post
Share on other sites

Depends on how you want to do it. You could always make it from scratch which is fairly simple or you can follow the tutorials for intergrating one of the GUI libraries into your project.

Share this post


Link to post
Share on other sites

I want to make it from scratch, from just simply using the sf::Shapes class. I don't want to get fancy because this is my first time making main menu.

 

I'm thinking to use the sf::Event::MouseButton::x and sf::Event::MouseButton::y, passing them to a function from a class called MenuButton, 

and then make an if statement with condition that checks if the mouse cursor is on the button's x and y locations.

 

I bet there's more easier way this this...

 

And sorry I already did some googling but couldn't find the material that I need.

 

EDIT:

 

Actually I can use getPosition() too...

Edited by Meerul264

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!