I tried to add text on top of the rects in the shop, but the text appeared behind the rects, why is this?
int clicks = 0;
color cookie;
color black;
color white;
PImage home;
boolean shop= false;
void setup() {
rectMode(CORNER);
size(660, 660);
background(100);
home= loadImage("home.png");
cookie = color(132, 86, 60, 255);
black = color(0, 0, 0, 255);
white = color(255, 255, 255, 255);
textAlign(LEFT);
textSize(30);
}
void draw() {
rectMode(CORNER);
background(100);
if (!shop) {
fill(cookie);
ellipse(width / 2, height / 2, height / 3, height / 3);
fill(0);
textSize(30);
text("clicks " + clicks, 20, 30);
rect(10, height/2+15, 60, 60);
fill(255);
textSize(25);
text("shop", 10, height/2+55);
}
if (shop) {
fill(0);
rectMode(CORNERS);
imageMode(CORNERS);
image(home, width/2-12, 2, width/2+13, 25);
filter(INVERT);
fill(38, 208, 213);
rect(10, 10, width/2-11, height/3-10);
rect(10, height/3+11, width/2-11, height/3+height/3-10);
rect(10, height/3+height/3+11, width/2-11, height/3+height/3+height/3-10);
fill(213, 38, 208);
rect(width/2+12, 10, width-10, height/3-10);
rect(width/2+12, height/3+11, width-10, height/3+height/3-10);
rect(width/2+12, height/3+height/3+11, width-10, height/3+height/3+height/3-10);
}
}
void mousePressed() {
if (!shop) {
if (get(mouseX, mouseY) == cookie) {
clicks++;
}
if (get(mouseX, mouseY) == black) {
shop=true;
}
}
if (shop) {
if (get(mouseX, mouseY) == white) {
shop=false;
}
}
}