We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › animation of images
Page Index Toggle Pages: 1
animation of images (Read 640 times)
animation of images
Sep 3rd, 2007, 2:37am
 
Hi
I'm trying to animate an image when i display a specific marker
I want the image to "fly" onto the screen
Not too fast !
I'm having trouble doing it
I dont understand martix's too well
I was wondering if someone could help please!
i tried using a while loop but it does not work well at all

Code:
 if (fiducial_id == 2)
{
xpos2 = xpos;
ypos2 = ypos;

a = loadImage("beck.jpg"); // Load the images into the program
b = loadImage("toots.jpg");
c = loadImage("mouseonmars.jpg");
d = loadImage("bjork.jpg");
e = loadImage("ninasimone.jpg");
f = loadImage("tomvek.jpg");




if (psize != 1) {
while (psize != 1) {
image(a, (xpos+sin((anglealbums)+angle)*radius)+300, ypos+cos((anglealbums)+angle)*radius, 50/psize, 50/psize);
// System.out.println(" "+ psize);
psize = psize - 1;
}
psize = 1;
}else{
image(a, (rxnum+xpos+sin((anglealbums)+angle)*radius)+250, rynum + 50+ypos+cos((anglealbums)+angle)*radius);
albums[0].setPosition(int(xpos+sin(anglealbums+angle)*radius),int(ypos+cos(anglealbums+angle)*radius));
}
Re: animation of images
Reply #1 - Sep 3rd, 2007, 8:47am
 
May be efficient.

a = (a!=null ? a : loadImage("beck.jpg"));
Re: animation of images
Reply #2 - Sep 3rd, 2007, 10:05am
 
Your code doesn't do what you think it does.

The screen does not update until the draw function is finished.

So all that while loop does is draw lots of images to a single frame, and so when the frame is actually displayed, all anyone will see is the largest image.

You need to have your scale variable defined outside the draw function, and vary it once per frame, and draw the image once. That way you'll be able to see it moving.
Page Index Toggle Pages: 1