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 › 1 declaration 2 functions
Page Index Toggle Pages: 1
1 declaration 2 functions (Read 444 times)
1 declaration 2 functions
Aug 4th, 2008, 6:47pm
 
hey everyone:
I am currently working on a script, and after spending many long hours, I have become very frustrated at this problem:
I am wanting to make my mousePressed/mouseReleased control two things at once.
so that ill say:
void mousePressed()(
line(mouseX,mouseY);
)
i also want mousePressed to
control another function, like popMatrix/pushMatrix...

any help would be appreciated thanks !
Re: 1 declaration 2 functions
Reply #1 - Aug 4th, 2008, 8:03pm
 
I don't understand what you want to do. Please give us your full example code or some more explanations.

By the way, you need brackets, and not parenthesis :

Code:
void mousePressed() {
// your instructions go here
}
Re: 1 declaration 2 functions
Reply #2 - Aug 4th, 2008, 9:06pm
 
*(sorry i meant brackets).

well i have:

void draw()
{
size(400, 400, P3D);
}

void mousePressed()
{
line(mouseX,mouseY);
}
void mouseReleased()
{
line(pmouseX,pmouseY);
}

void mousePressed()
{
rect(mouseX,mouseY,40, 40);
}


and so that at every starting point where I call mousePressed to begin a line it will also make a rectangle ...


thanks again.
Re: 1 declaration 2 functions
Reply #3 - Aug 4th, 2008, 9:16pm
 
You can just put both into the first mousePressed...

Code:
void mousePressed()
{
line(mouseX,mouseY); //though line needs 4 arguments like rect
rect(mouseX,mouseY,40, 40);
}
Re: 1 declaration 2 functions
Reply #4 - Aug 6th, 2008, 3:20pm
 
thanks for helping me.
i finally got it to work!
Page Index Toggle Pages: 1