OK - on closer inspection I see the problem.
The thing about size still stands - not following that rule can lead to weird and unexplainable problems down the line; which is why I saw that and assumed it was the cause here. In actual fact the issue here is much more mundane:
Quote:class Bear{
float r;
float x,y;
Bear(float tempR){
r=tempR;
x=mouseX;
y=mouseY;
}
void displayBear(){
//Draw bounding-box for bear image.
ellipse(mouseX,mouseY+3,40,40);
//Draw bear icon to follow mouse.
image(bo,mouseX,mouseY, bo.width*.4, bo.height*.4);
}
//Function to return true or false based on if bear intersects
//a honey pot
boolean intersect(Honey h){
float distance=dist(x,y,h.x,h.y); //Calculate distance
if(distance<r+h.r){ //Compare distance to sum of radii
return true;
}
else {
return false;
}
}
}
You set the bear's x and y properties to MouseX/Y only once: at the moment of the bear object's creation... But then don't update it; so it's checking collisions against the position of the mouse when the sketch was run. Things look like they're working because of course you're drawing the bear by referencing mouseX/Y directly. Instead try this in your original code:
Code:void displayBear(){
// Update x/y to current mouse position
// (this will then be used in the hit test)
x=mouseX;
y=mouseY;
//Draw bounding-box for bear image.
ellipse(x,y+3,40,40);
//Draw bear icon to follow mouse.
image(bo,x,y, bo.width*.4, bo.height*.4);
}