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 › Re: New - Pls. help
Page Index Toggle Pages: 1
Re: New - Pls. help (Read 423 times)
Re: New - Pls. help
Nov 29th, 2009, 3:00pm
 
Use a variable.  In this case, as you only have two states, a boolean should do; or in theory you could simply store the text in a String variable.  When the mouse is pressed check the value of the variable (using a condition) to determine what text to display and then change the value of the variable so next time you get a different result.  Give it a try, using the Reference and basics section if you need examples.  If you can't get it working post your code here and I'm sure someone will help Wink
Re: New - Pls. help
Reply #1 - Nov 29th, 2009, 3:27pm
 
what he ment was to create another variable. As you only switch between 2 states you can use a boolean variable. This could be either false or true. So in your case "love me" or "love me not". If you have more than two strings use an int.

so what we need to do is declare the variable

boolean love = true;

then in draw write something like this

if(love){
text("loves me",x,300);}
else{
text("loves me not",x,300);
}

//there are different ways to do that. change the String itself. or use different strings or whaterver. this is just one solution.


and in mousePressed you have to change either your variable is true or false.
The easiest way to do is to say

love = !love;

this reads "make love the opposite of what love is right now" so if its true it turns false and vice versa.

Hope that helps you.

Re: New - Pls. help
Reply #2 - Nov 29th, 2009, 3:37pm
 
That was poetic!

And it worked.

Thank you  Kiss
Page Index Toggle Pages: 1