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

setEnd()

Description

Sets a method to execute when the Animation finishes all its repetitions. The specifed method must be prototyped as:
void myEndMethod();
Where the specified method must return void and take no parameters.

Prototype

setEnd(method_name);

Parameters method_name String representation of the method; eg. the method void myEndMethod() is passed in this parameter as the String "myEndMethod".
Return   (none)
Example

 

Animation test;
BFont font;
String status = "The animation is running.";

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.showRectangle();
  test.setRepetitions(1);
  test.setDuration(10000);
  test.setEnd("testEnd"); // call testEnd() when animation finishes.
}

void loop()
{
  background(127);
  test.draw();
  text(status, 25, 25);
}

void testEnd()
{
  status = "The animation has ended.";
}