Sign in to follow this  
Hankenstien

buttons that have a render method

Recommended Posts

Hankenstien    134

I posted the other day in Graphics and Therory forum and I don't think I phrased my question right.  Maybe this is more of a beginners question anyways.  I want to make a UI for a game.  My game uses a game loop that calls update and render methods.  So as of right now I am making  a button class that implement MouseListener/ MouseMotionListener. 

These buttons are very basic they have:

 -Rectangle2D for the button its self

 -they have a boolean called "hover"  that is set to true if the mouse is contained in that Rectangle2D

 -they have a render method to render it to the screen

 

There is a bit more code and I am simplifiing the process a bit, but am I on the right track or should I be doing something different.

Share this post


Link to post
Share on other sites
Hankenstien    134

Ok, but what are you trying to accomplish? I don't see a question smile.png

Sorry Lysy what I want to know is am I doing what you would do to create components for a UI on a game that uses a loop for updating and rendering objects to the screen.  Is there another way to make UI's for this type of game since the screen is getting redrawn 60 times a second or whatever I have it limited to.  I just want to know the correct way to do it.

Share this post


Link to post
Share on other sites
Lysy    685

 

Sorry Lysy what I want to know is am I doing what you would do to create components for a UI on a game that uses a loop for updating and rendering objects to the screen.  Is there another way to make UI's for this type of game since the screen is getting redrawn 60 times a second or whatever I have it limited to.  I just want to know the correct way to do it.

 

Yeah, you're doing it right. All the elements that render on screen should be called in a game loop. I think you should also do some research on 'state machines'. You will be able to create menu, game screen and many others, and your code will stay clear and will attract females.

 

Also I recommend this famous article about managing game loop:

http://www.koonsolo.com/news/dewitters-gameloop/

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