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 › pressing objects
Page Index Toggle Pages: 1
pressing objects (Read 805 times)
pressing objects
May 22nd, 2010, 3:30am
 
hi guys, i'm brand new to processing, and pretty new to programming in general. I've been writing a simple tictactoe game in processing, and managed to it it. However, in an effort to improve my skill and streamline the code, i wanted to redo it using objects

i have created a space class, that is invisible and sets in-between the lines.
I cannot figure out how to receive a mousepress signal from the object. I tried to create the function in the constructor, but this fails to work.
How can i get a real time function, that keeps checking if the object has been pressed?
here is a link to the source code. Its quite messy due to my inexpreience with programming, but it does work
(see post below)

if any one can be of assistance, or doesn't quite get what i'm rambling on about, please say.
Re: pressing objects
Reply #1 - May 22nd, 2010, 3:30am
 
http://dl.dropbox.com/u/2793727/tto_objects.txt
Re: pressing objects
Reply #2 - May 22nd, 2010, 3:31pm
 
Well, as in "regular" Processing, you can manage such event either in the mousePressed() main method (outside of a class, at sketch level) or check the mousePressed boolean in draw().
In the first case, it means the mouse have been pressed on the sketch, and the method must call the mousePressed() function in the objects that what to manage the event (eg. checking the event against their bounds, etc.).
In the second case, draw() must call each time a mouseCheck() function (for example) in the objects.

As in plain sketches, I prefer the event (first one) version.
Page Index Toggle Pages: 1