Sign in to follow this  
Artum

UI implementaion question.

Recommended Posts

Howdy. Let's get this out of the way: C++, Dev-C++, SDL So I've got a little game I'm making for myself (yeah who doesn't). In my game I'm at the point when I'd like to start adding in some UI: healthbars, hotbars, menus, and that sort of thing. I've been using SDL_Rects and the mouse coordinates to see if a button was clicked on; if the coords are within the Rect and the mouse button was clicked then the UI button has been clicked. So far it's been working out, but I just wanted to check with the community and see if anyone has a better idea on how to get UI interaction. Thanks in advance, -Artum.

Share this post


Link to post
Share on other sites
You may want to organize UI elements into a hierarchy, much like a scene graph. If you ever have movable elements, or any situation in which they may overlap, it could help you determine which element gets the event message by propagating it through parent-child relationships.

You also might want to consider giving the elements layer indices or z-values, which are also helpful in case of overlap or unexpected resolutions or things like that.

Aside from that, I'd say just do it the way it works. I used to spend entirely too much time designing, and not enough actually getting things done.

Share this post


Link to post
Share on other sites

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