Sign in to follow this  

SDL main menu

This topic is 1107 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

Are there any tutorials to show me how to go about making a main menu with buttons? For example, how to recognize where the mouse is so when the button is pressed, it will take me to my game.

 

Many thanks!

Share this post


Link to post
Share on other sites

I would just get the position values of the MouseEvent, if it is a DownEvent. ( http://wiki.libsdl.org/SDL_MouseButtonEvent?highlight=%28\bCategoryStruct\b%29|%28SDLStructTemplate%29 )

Then you could check it against the position of your buttons and if it is inside, activate it.

 

There is a more extensive tutorial at Lazy Foo:

http://lazyfoo.net/tutorials/SDL/17_mouse_events/index.php

 

I wouldn't do it that way, because you check for the current mouse position, when you handle the event and if are running slow, because you already had to handle many events, there can be some lag and the mouse position is off. That could lead to the user clicking the wrong button, altough it is hard to actually move the mouse that fast. I just don't think, that solution is "clean".

 

Good Luck,

Neko

Share this post


Link to post
Share on other sites

This topic is 1107 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this