Using the mousePressed Variable with an image sequence
The counter only increases when the mouse is pressed
(Same set of images as the last example)
/* mousePressed Flipbook */
PImage zero;
PImage one;
PImage two;
PImage three;
PImage four;
PImage five;
int counter=0;
void setup()
{
size(640,480);
zero = loadImage("zero.jpg");
one = loadImage("one.jpg");
two = loadImage("two.jpg");
three = loadImage("three.jpg");
four = loadImage("four.jpg");
five = loadImage("five.jpg");
}
void draw()
{
if (mousePressed)
{
counter++;
if (counter>5)
counter=0;
}
if (counter == 0)
{
image(zero,0,0);
}
if (counter ==1)
{
image(one,0,0);
}
if (counter==2)
{
image(two,0,0);
}
if (counter==3)
{
image(three,0,0);
}
if (counter==4)
{
image(four,0,0);
}
if (counter==5)
{
image(five,0,0);
}
}





