class RectButton extends Button { float mWidth; float mHeight; RectButton( float posX, float posY, float _width, float _height ) { super( posX, posY ); setSize( _width, _height ); } void setSize( float _width, float _height ) { mWidth = _width; mHeight = _height; } void drawShape() { rectMode( CENTER_DIAMETER ); float scale = calcScale(); rect( mPosX, mPosY, mWidth * scale, mHeight * scale ); } boolean isHit() { float dx = mouseX - mPosX; float dy = mouseY - mPosY; if( -mWidth / 2 < dx && dx < mWidth / 2 && -mHeight / 2 < dy && dy < mHeight / 2 ) { return true; } return false; } };