I want to press one time to display all the elements,
why I should press two times to display the 0 elements?
I try to order the if statements but I didn't figure it out.
here is the link fiddle
var words = ['rainbow', 'heart', 'purple', 'friendship', 'love'];
function setup() {
createCanvas(400, 400);
}
function draw() {
background(0);
textSize(32);
text(words[i]);
}
function mousePressed() {
for (let i = 0; i < words.length; i++) {
text(words[i], 100, i * 50 + 50);
if (i == 0) {
fill(255, 0, 0);
}
if (i == 1 ) {
fill(0, 50, 100, 300);
}
if (i == 2) {
fill(0, 165, 300, 200);
}
if (i == 3) {
fill(0, 50, 100, 300);
}
if (i == 4) {
fill(0, 50, 100, 300);
}
}
}
Aucun commentaire:
Enregistrer un commentaire