So I’m trying to figure out how to make one of my images appear and stay ON SCREEN with mousePressed, but it always goes away. Is there a way I can make it stay on screen? (I’ve also tried to do the same with mouseClicked function, but that didn’t work either…)
Here’s my code…
The basic for loop structure has three parts, and something crucial is missing in the test part. The answer is well hidden on the reference page
Did you consider to load three separate images, rather than filling the array with the same image “bot.png”? You can achieve it by adding one line of code inside your for loop and slightly adjusting the other. (ps. let us know if you need a little bit more than that, but it’s good exercise if you try to solve it on your own).
Embarrassing to say this, but I think I need a little bit more than that…though, I kind of assumed that the array would automatically format the three images since I named it “bot.png, bot1.png, bot2.png”
Not a problem, and no reason to be embarrassed! I’ll help you get there. You’re already somewhat close with your assumption that it would load “bot1.png” and “bot2.png”. The question now is how to make good use of the for loop, so it loads those exact file names.
Try the following code in a new Processing sketch and observe the output in the command line:
for (int i = 0; i < 3; i++) {
println("this is loop number " + i);
}
You notice how I use the for loop to construct the output? In a similar manner you could construct file names– use a variable to construct the right file name, and use that variable to load a specific image.