class Button { float _myX; float _myY; int _myWidth; int _myHeight; boolean isInside = false; color c; color c0 = color(0,0,0,255); color c1 = color(0,0,0,128); PImage myImage; public Button(float theX, float theY, int theWidth, int theHeight, String theImageFile) { _myX = theX; _myY = theY; _myWidth = theWidth; _myHeight = theHeight; myImage = loadImage(theImageFile); } void draw() { // c = (isInside)? c0:c1; if (isInside) { c = c0; } else { c = c1; } if(isDown && isInside) { _myX = mouseX-_myWidth/2; _myY = mouseY-_myHeight/2; } noStroke(); fill(c); //rect(_myX,_myY,_myWidth, _myHeight); image(myImage, _myX, _myY, _myWidth, _myHeight); } boolean check(int theX, int theY) { if(isDown) { isInside = ((theX>(_myX)) && (theX<(_myX+_myWidth)) && (theY>(_myY)) && (theY<(_myY+_myHeight))) ? true:false; } return isInside; } void reset() { isInside = false; } }