Ok so I am trying to create bubbles that dissappear when you click on them
The problem I'm having is that when you click on a bubble, all of them disappear even though I only want the one that is clicked on to dissappear.
Does anyone know how to seperate these identical circles so that they disappear individually?
Any help would be much appreciated!
Here my code:
// make some circle objects (Circle is a custom object
// defined below
MovingCircle Circle = new MovingCircle(250,250,100);
MovingCircle Circle2 = new MovingCircle(250,250,100);
MovingCircle Circle3 = new MovingCircle(250,250,100);
MovingCircle Circle4 = new MovingCircle(250,250,100);
MovingCircle Circle5 = new MovingCircle(250,250,100);
MovingCircle Circle6 = new MovingCircle(250,250,100);
MovingCircle Circle7 = new MovingCircle(250,250,100);
color circleColor, baseColor;
color circleHighlight;
color currentColor;
boolean circleOver = false;
int circleX, circleY; // Position of circle button
int circleSize = 93; // Diameter of circle
// update the position of the circles
Circle.update();
Circle2.update();
Circle3.update();
Circle4.update();
Circle5.update();
Circle6.update();
Circle7.update();
// check for collisions with the walls
Circle.checkCollisions();
Circle2.checkCollisions();
Circle3.checkCollisions();
Circle4.checkCollisions();
Circle5.checkCollisions();
Circle6.checkCollisions();
Circle7.checkCollisions();
// and draw each one
Circle.drawCircle();
Circle2.drawCircle();
/* only need one drawCircle() function -> all objects share it*/
}
// this is the definition for our custom MovingCircle object,
// start with the name of the class (or type of object)
class MovingCircle {
// any variable declared here will be properties of
// objects of this type
float x;
float y;
float xSpeed;
float ySpeed;
float circleSize;
boolean overCircle;
// this special function declaration has the same name
// as the class (MovingCircle) and it has no return type. This
// is known as the constructor and it's run when an
// object of this type is created.
MovingCircle(float xpos, float ypos, float csize) {
x = xpos;
y = ypos;
circleSize = csize;
xSpeed = random(-1, 1);
ySpeed = random(-1, 1);
}
// update adds the speed to the position, making
// our circle move around.
void update() {
x += xSpeed;
y += ySpeed;
}
// this function checks to see if our circle has gone off
// the edge of the screen, and if so reverses the speed