Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


buttons that have a render method


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Hankenstien   Members   -  Reputation: 134

Like
0Likes
Like

Posted 08 August 2014 - 09:26 AM

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.



Sponsor:

#2 Lysy   Members   -  Reputation: 685

Like
0Likes
Like

Posted 08 August 2014 - 10:41 AM

Ok, but what are you trying to accomplish? I don't see a question :)



#3 Hankenstien   Members   -  Reputation: 134

Like
0Likes
Like

Posted 08 August 2014 - 11:01 AM

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.



#4 Lysy   Members   -  Reputation: 685

Like
1Likes
Like

Posted 08 August 2014 - 11:20 AM

 

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/



#5 Hankenstien   Members   -  Reputation: 134

Like
0Likes
Like

Posted 08 August 2014 - 11:47 AM

Excellent!! Thanks Lysy that articale will give me something to read at work today.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS