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 › Background Change
Page Index Toggle Pages: 1
Background Change (Read 402 times)
Background Change
Oct 25th, 2007, 5:55pm
 
I'm having problems changing the background at certain times. I've loaded a file into processing using Ess and at 4 points I want it to change. I want it to change at 0, 419825, 779375 and 1021175 frames respectively. The code I'm using looks like this:

int frame = 0; //setting some parameters
int fear[] = {0}; // 1st part and the time to start it
int anger[] = {419825}; // 2nd part and time to start it

void draw() {
 frame++;
 backgrounds();
}

void backgrounds(){
 for (int i=0;i<fear.length;i++){
   if (frame!=fear[i]);
   background(0); // color of the background
   return;
 }
 for (int i=0;i<anger.length;i++){
   if (frame!=anger[i]);
   background(130,0,0);
   return;
 }
}

N.B. There have been things left out like void setup, but you shouldn't need that.

Does anybody have any suggestions for me???
Re: Background Change
Reply #1 - Oct 25th, 2007, 7:25pm
 
a: You don't need to keep a frame variable, processing has an internal one "frameCount".
b: I think you want == not != in your if(...) blocks in backgrounds()
Page Index Toggle Pages: 1