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 & HelpPrograms › Re: Struggling!!
Page Index Toggle Pages: 1
Re: Struggling!! (Read 541 times)
Re: Struggling!!
Mar 11th, 2010, 4:27pm
 
"Except I don't want it to appear only until I click my mouse."

Does this mean you only want it to appear when the mouse is clicked, or that you want it to be visible all the time and just move when the mouse is clicked?
Re: Struggling!!
Reply #1 - Mar 11th, 2010, 4:42pm
 
You're obviously very confused, and I think the best course of action is to go through some tutorials to improve your understanding.

If you follow some working code with explanations for a while, perhaps it will make more sense.

If you don't understand that you need to use "if (...)" or something similar to change the behaviour of the draw() method based on some condition (such as the mouse being pressed), you will not likely understand the solution. So far you are having trouble just explaining what you want.

if (mousePressed) { ... } means do the part inside the curly brackets if the mouse is pressed. mousePressed is a BOOLEAN VARIABLE, with value true or false. The void mousePressed() method has the same name but is a different thing - it gets CALLED when the mouse is pressed, and inside that method you are setting some LOCATION variables, but not keeping track of whether the mouse is CURRENTLY PRESSED or not. The mousePressed variable keeps track of this for you, so what you need to do is write, as I showed you before:

Code:
draw()
{
 // The circle drawn whether the mouse is pressed or not
 ellipse(x1, y1, size1, size1);

 if (mousePressed)
 {
   // The circle which only appears when the mouse is pressed
   ellipse(x2, y2, size2, size2);
 }
}


If this does not make sense, please do not ask again until you have done some tutorials. You won't learn anything thrashing around without some basic ideas to start you off.

-spxl
Re: Struggling!!
Reply #2 - Mar 11th, 2010, 5:19pm
 
Don't worry! Got it working now!

Thanks anyways!
Page Index Toggle Pages: 1