Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Mouse hover system in LWJGL


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
No replies to this topic

#1 Dth   Members   -  Reputation: 105

Like
0Likes
Like

Posted 17 August 2013 - 06:02 AM

Hi.

I am new to LWJGL and I have been busy making a small game to try and get myself better acquainted with the library. I have a small issue though.

 

I have an ArrayList of Entities.

These Entities all have a parent controller that manages certain variables.

 

This method works for rendering and movement, but when I try and create a sort of "mouse hover" system for the Entities, it causes issues and doesn't seem to work properly.

 

This is the code that I currently have to handle 'hover':

(This is performed by the controller which has an ArrayList of Entities)

for (Entity e: entities){
        //isInRegion(regionX1, regionY1, regionX2, regionY2, testX, testY). Returns boolean
	if (isInRegion(e.getX(), e.getY(), e.getX()+e.getWidth(), e.getY()+e.getHeight(), Mouse.getX(), Display.getHeight()-Mouse.getY()))){	
		e.setHover(true);
	}
	else{
		e.setHover(false);
	}
}

I know that the isInRegion() method works correctly because i've tested it.

 

What I ideally want to be able to do is draw an ellipse around the currently "hovered" Entity, BUT, not draw a circle over an Entity that isn't selected.

 

Could anyone tell me how I might achieve this?



Sponsor:



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