boolean isPressed = false; // ボタンが押されているかどうか boolean isHovered = false; // ボタンの上にマウスが来ているかどうか int count = 0; // ボタンが押された回数 int bx = 100; int by = 200; int bw = 200; int bh = 100; void setup(){ size(400, 400); textAlign(CENTER); } void draw(){ background(255); // ボタンの状態に従ってボタンの色を変える // ボタンや回数を描画する rect(bx, by, bw, bh); fill(0); text("Press", bx + bw / 2, by + bh / 2); text(count, 200, 100); } // (x, y) がボタン上かどうかを判定する boolean isOnTheButton(int x, int y){ return x > bx && x < bx + bw && y > by && y < by + bh; } void mousePressed(){ } void mouseReleased(){ } void mouseMoved(){ }