Animated button ?
in
Contributed Library Questions
•
4 months ago
So I'm trying to create a button that is a .gif, when the button is clicked it should play through the animation and then stop on the beginning frame while also performing the second function of the button placing an Image at random.
Right now I have the second function working but can't get the animation to play when clicked ?
import gifAnimation.*;
float x = 200;
float y = 50;
float w = 30;
float h = 30;
float ranNum;
int ranNumRound;
PImage img;
Gif loopingGif;
void setup(){
size(1000,600);
background(255);
stroke(0);
frameRate(5);
loopingGif = new Gif(this, "Blinking.gif");
String [] animas = {};
}
void draw(){
image (loopingGif, 200 , 50);
}
void mousePressed(){
if(mouseX>x && mouseX <x+w && mouseY>y && mouseY <y+h){
loopingGif.play();
}
else {
loopingGif.pause ();
ranNum = random(9);
ranNumRound = round(ranNum);
println(ranNumRound);
img = loadImage("images/pic"+ ranNumRound +".gif");
image(img,random(width),random(height),img.width,img.height);
}
}
1