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 › How do you make text refresh
Page Index Toggle Pages: 1
How do you make text refresh? (Read 638 times)
How do you make text refresh?
Jan 23rd, 2010, 5:22am
 
I've got text being displayed and I want to refresh it with new text... this seems like it should be very easy....
Re: How do you make text refresh?
Reply #1 - Jan 23rd, 2010, 6:35am
 
just use text() again...

does this code help you?
Code:
PFont arial;
int currentTextID = 0;
String texts[] = new String[]{"lorem", "ipsum", "dolor", "sit", "amet"};

void setup()
{
size(150, 150);
background(80);
arial = createFont("Arial", 15);
}

void draw()
{
background(80);
textFont(arial);
fill(255);
text(texts[currentTextID], 50, height/2);
}

void keyPressed()
{
if(key == ENTER)
{
if(currentTextID < texts.length - 1)
{
currentTextID++;
}

else
{
currentTextID = 0;
}
}
}
Page Index Toggle Pages: 1