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

setDuration()

Description

Sets the duration of an Animation, in milliseconds (thousandths of a second). Default is 1000.

Setting a duration overrides any previously set duration, including one defined by setFrames().

To retrieve the percentage complete that the Animation is, use currentPercentage().

Prototype

setDuration(time);

Parameters time Milliseconds of time (as the primitive 'long') the Animation must take to complete one repetition.
Return   (none)
Example

 

 

Animation test;

void setup()
{
  size(400,100);
  test = new Animation(this, loadImage("image.gif"), 100,40, 200,40);
  test.showRectangle();
  test.setDuration(5000); // set duration to 5 seconds.
}

void loop()
{
  background(127);
  test.draw();
}