Animation Overview - News - Installation - Reference - Examples - FAQ  
 

setRepetitions()

Description

Sets the number of times for an Animation to repeat. Setting 0 makes the Animation repeat forever. Default is 0.

To retrieve the number of repetitions set for the Animation, use repetitions(). To retrieve the current repetition, use currentRepetition().

Prototype

setRepetitions(count);

Parameters count Number of times the Animation should repeat before it disappears. (Set to 0 to repeat forever.)
Return   (none)
Example

 

Animation test;
BFont font;

void setup()
{
  size(400,100);
  font = loadFont("RotisSanSer.vlw.gz");
  textFont(font, 20);
  
  test = new Animation(this, loadImage("image.gif"), 100,40, 200,40);
  test.setDuration(10000);
  test.showRectangle();
  test.setRepetitions(10); // perform ten repetitions
}

void loop()
{
  background(127);
  test.draw();
  text("Repetition: " + (int)test.currentRepetition() + "/10", 25, 25);
}