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 › Instances talking to each other
Page Index Toggle Pages: 1
Instances talking to each other (Read 356 times)
Instances talking to each other
Feb 8th, 2008, 7:38pm
 
Hi,

I'm playing with Dan Shiffman's basic particle system.

http://www.processing.org/learning/topics/simpleparticlesystem.html

I was each particle to be able to access the particles arrayList in the ParticleSystem Class, but am unsure how I should approach it.

I've tried passing the particles arraylist as a parameter to the particle, but only get syntax errors. Is there a way to access a parent class's variables?

Any tips?
Re: Instances talking to each other
Reply #1 - Feb 9th, 2008, 5:53am
 
If you want something shared throughout all instances of an object you can try playing with static members.

For example

class Thing{
 static float num = 0;
}

"num" now exists only once, in all instances of Thing.
Page Index Toggle Pages: 1