Clicked() function? [Resolved]


#1

Hello, I am following the Coding Train 7.4 tutorial, if anyone has seen this, and I am unable to allow the program to recognize when I click inside the circles. In the video, the functions are formatted like this:

function mousePressed() {
  for (let i = 0; i < bubbles.length; i++){  
    bubbles[i].clicked(mouseX, mouseY);
}
}

clicked(px,py) {
  let d = dist(px, py ,this.x,this.y);
  if (d < int(this.r/2)){
  	this.brightness = 255;
  console.log("Clicked on bubble");
}
}

The system says I need to place a semicolon after clicked, but this is not correct. What is incorrect about clicked()? Do I need to use mouseClicked() instead?

To anybody reading this, I have resolved the issue. No assistance is needed.


#2

Did you need to add the function keyword in the line above?

I notice you do not need assistance anymore. I suggest you create a new post updating the community about your issue instead of editing your post so people can see your update message promptly. Also, it is encourage to share your solution so to help other forum goers in the feature having the same issues.

Kf


#3

Seeing as the clicked function has this. in it, I’m assuming all he needed to do was move the function to inside the Bubble class, rather than having it outside.