I tried you method and it tells me the global variable “showit” does not exist. I may have done something wrong.
boolean showit = false;
PImage[] planetDiffuse = new PImage[2];
float x = 500;
float y = 110;
void setup() {
size (1600, 800);
for (int i = 0; i < planetDiffuse.length; i++) {
planetDiffuse[i] = loadImage("land" + i + ".png");
}
}
void draw() {
background(0);
if (showit) {
image(planetDiffuse[int(random(planetDiffuse.length))], x, y);
}
}
void keyPressed() {
if (key == 'A') {
planetDiffuse[0].showit = ! planetDiffuse[0].showit;
}
}