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 › displaying image problem
Page Index Toggle Pages: 1
displaying image problem (Read 477 times)
displaying image problem
Jan 6th, 2008, 7:11pm
 
hi

i work on a project where a long text is written on the screen character by character. when the end of the screen is reached it starts over at the top. the characters are displayed as images. now, when there is a character from the previous pass, before i display the new one i would like to delete the old one by displaying a blank black image briefly. however even if i set the time between drawing the blank and the new image to, say, 2 seconds it seems as if they are both drawn at the same time, so the blank is actually lost.

this is my code:

Quote:
void display(int idx) {
 if (words[idx] != '$') {
   image(imgSpace, c, l);
   float a = millis();

   while((millis()-a)<1000){
   }

   image((PImage)alphabet.get(new Character(words[idx])), c, l);
 }
}


i call display() from draw().

any ideas?

cheers
nadja
Re: displaying image problem
Reply #1 - Jan 6th, 2008, 7:23pm
 
Nothing actually gets drawn to screen until draw() finishes, so putting any kind of delay in a function called during draw will just make it take longer to give the same result.

To get the effect you want, you'll have to have two states, one "do nothing during draw" and the other "do something". When you get to a point you want to pause, you clear the letter you want to remove, then set a value to "do nothing next time", next time comes, and it does nothing until however long has passed, and then changes the variable back to "do something next time"
Re: displaying image problem
Reply #2 - Jan 6th, 2008, 7:26pm
 
that was quick. thanks a lot.

cheers
nadja
Page Index Toggle Pages: 1