Processing/Java help

Soldato
Joined
6 Jun 2011
Posts
2,741
Hey guys,

I am currently creating a program using processing. However I am having a real problem with if statements. I have lots of different if statements which take up a lot of lines of code. I have tried putting them into a function using local variables, but the result of these if statements is to change a global variable and I cannot make it work. Here is the kind of thing I am talking about:


Any ideas? Any help appreciated.

Thanks :)
 
Last edited:
The issue I am having is that each if statement is checking for the mouse position inside a button. The above code is an example but it is exactly what I have which works fine. However as I have so many buttons I have an awful lot of if statements and I was wondering if it is possible to use a function with one if statement that can be used for all.

Hope this makes sense.

Thanks :)
 
Can you not just do a function something like this? It does not work though because this is what I am having a problem with. I need the value of speed to be given to the example and example1 variable.



Thanks guys
 
Last edited:
Hi there,

Thanks for the response. I have everything working, it's just I did not want a seperate if statement for each button. I was hoping I could have a kind of universal if statement in a function.

It's basically to cut the lines of code.

Thanks :)
 
Back
Top Bottom