vendredi 8 mai 2015

Error in checking for if mouse is in tolerance

I have a rect, which I want to disappear when it's getting clicked.

I use the following method to control if the mouseX and height*0.9 is in the area of the rectangle when clicked:

//balken is a ArrayList of the object holding the variables for the rectangle
boolean mouseInTolerance()
{
  return ((mouseX > balken.get(0).x- balken.get (0).balkenWidth*.5
      || mouseX < balken.get(0).x+ balken.get (0).balkenWidth*.5)
      && (height*.9 > balken.get(0).y- tolerance
      || height*.9 <balken.get(0).y+ tolerance));

However, this returns true no matter where the mouse has been clicked.

Edit: rectMode is set to CENTER

Aucun commentaire:

Enregistrer un commentaire