Example |
Animation test;
Animation a_box;
Animation an_ellipse;
BFont font;
void setup()
{
size(400,100);
font = loadFont("RotisSanSer.vlw.gz");
textFont(font, 20);
a_box = new Animation(this, loadImage("image.gif"), 0,0, 20,20);
a_box.setStep("BOX");
a_box.showRectangle();
an_ellipse = new Animation(this, loadImage("image.gif"), 0,0, 10,-40);
an_ellipse.setStep("ELLIPSE");
an_ellipse.showRectangle();
test = new Animation(this, a_box, 100,40, 200,40);
test.setDuration(10000);
test.showRectangle();
}
void loop()
{
background(127);
if (test.currentPercentage() < 0.5)
test.setAnimation(a_box);
else
test.setAnimation(an_ellipse);
test.draw();
Animation current = test.animation(); // retrieve the nested animation.
if (current == a_box)
text("Inner animation is a box.", 25, 25);
else
text("Inner animation is an ellipse.", 25, 25);
}
|