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

setTest()

Description

Sets a method to execute in draw() before drawing the Animation each frame. This method determines whether or not the Animation should finish immediately. The specified method must be prototyped as:
boolean myTestMethod();
where the specified method must return a boolean (true if the Animation has ended; false otherwise), and take no parameters.

To restart a finished Animation, use reset().

Prototype

setTest(method_name);

Parameters method_name String representation of the method; eg. the method void myTestMethod() is passed in this parameter as the String "myTestMethod".
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.showRectangle();
  test.setTest("shouldAnimationEnd"); // sets the test method, defined below.
}

void loop()
{
  background(127);
  test.draw();
  text("Click to end the animation.", 25, 25);
}

boolean shouldAnimationEnd()
{
  if (mousePressed)
    return true;
  else
    return false;
}