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 › just a bit of help
Page Index Toggle Pages: 1
just a bit of help (Read 401 times)
just a bit of help
Oct 26th, 2009, 2:46am
 
I’m new to processing, and have been flicking through the programme and getting to grips with it, I have been trying to combine a simple animation from the basic tutorials page with a jpg as the back ground rather than a block colour, but I cant get it to work, anyone want to look over and explain where I’ve gone wrong?

Here is the code:


int currentFrame = 0;
PImage[] frames = new PImage[24];
int lastTime = 0;

void setup()
{
 size(640, 518);
 strokeWeight(12);
 PImage b;
 b = loadImage

("   "); // any jpg from a web page, i've left it blank on here, as my first post it wont let me past a URL

 for (int i = 0; i < frames.length; i++) {
   frames[i] = get();
 }
}

void draw()
{
 int currentTime = millis();
 if (currentTime > lastTime+30) {
   nextFrame();
   lastTime = currentTime;
 }
 if (mousePressed == true) {
   line(pmouseX, pmouseY, mouseX, mouseY);
 }
}

void nextFrame()
{
 frames[currentFrame] = get();
 currentFrame++;
 if (currentFrame >= frames.length) {
   currentFrame = 0;
 }
 image(frames[currentFrame], 0, 0);
}
Re: just a bit of help
Reply #1 - Oct 27th, 2009, 3:04pm
 
Well, you load the image b but you don't use it. It doesn't go automatically one the sketch's surface. So all your get() calls will just grab the default background color, if I read correctly.
I am not sure what you plan to do with all the PImages, since you load only one image.
Page Index Toggle Pages: 1