Wednesday 15 May 2013

slick2d - Finding if my mouse is inside a rectangle in Java -


I am starting to develop a game and I should be able to see if my mouse is inside the rectangle, Have tried to use. Is included for a rectangle but I can not seem to work for it, I will paste my code below, any help would be greatly appreciated! :)

  Public Boolean Hammausover (GameCenter GC) {R = new rectangle (getX), getY (), getWidth (), getHeight ()); Input input = gc.getInput (); Xpos = input.getMouseX (); Ypos = input.getMouseY (); Return RC Contains (Expos, UPS); }   

This is the method I am trying to use, but when the mouse is inside the rectangle, it keeps returning incorrectly. Obviously, I pushed xpos, ypos, and rectangle, and I called that method in the method of the method which I am trying to use it.

You have two digits for your mouse, it's x and w is paused.

  int mouseX = gc.getInput (). GetMouseX (); Int mouseY = gc.getInput (). GetMouseY ();   

And we have a rectangle

  rectangle REC = new rectangle (100, 100, 200, 200);   

Then we can see

  if (mousex => rec.getMinX () & amp; amp; & amp; amp; & amp; amp; & amp; amp; amp; & lt; = rec .getMaxX) // Check that the X is within the bounds & amp; Amp; (Mouse U> = rec.getMinY () & amp; amp; amp; amp; amp; amp; & amp; ;;; rec.getMaxY) // Check that y is within range   

Or now we know that our X value is less than the lower value of the rectangular ones, but it is less than the higher value, and lets see the same function for Y.

to check

  xp - y (float XP, float yap, float xr, float yar, float width, float height) X coordinate of point - point to point y Checking XR to XC - X coordinate of rectangular yr - y coordinate of rectangular width - Width of rectangular height - Height of rectangle   

then I would say

In it (mouseX, mousey), Rec.getMinX (), rect.getMinY (), rec.getWidth (), rec.getHeight ()) Maybe something was going wrong here?

No comments:

Post a Comment