I want to have text printed out on the condition that the mouse positions hover over a certain coordinate range for both x and y coordinates. However, the text can not print even if I state in the code that the text should be printed if its on a certain coordinate range. Can anyone offer me some advice towards what I should be doing? Any help can be appreciated.
The code to print the text is after the "// Gamma" comment
PImage[] imgs;
String[] greekAlphabet = {"Gamma", "Zeta", "Eta", "Kappa", "Lambda", "Phi", "Psi"};
void setup(){
background(0);
size(500, 500);
textSize(50);
textAlign(CENTER, CENTER);
imgs = new PImage[greekAlphabet.length];
for (int i = 0; i < imgs.length; i++){
imgs[i] = loadImage(greekAlphabet[i]+".png");
}
text("Press Any Key", width/2, height/2);
}
void draw(){
if (keyPressed){
background(0);
text("Choose any clan", width/2, height/2 - 180);
for (int i = 0; i < imgs.length; i++){
if (i >= 0 && i <= 3){
image(imgs[i], (((i)%5 * 120)), 120, 150, 150);
}
else if (i >=4 && i <= 6){
image(imgs[i], (55+((i)%4 * 120)), 310, 150, 150);
}
}
// Gamma
if (overImage(25, 120, 140, 250)){
text("Gamma", width/2, height/2);
}
}
println(mouseX + " " + mouseY);
}
boolean overImage(int x1, int x2, int y1, int y2){
if ((mouseX >= x1 && mouseX <= x2) && (mouseY >= y1 && mouseY <= y2)){
return true;
}
else{
return false;
}
}