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 › Problem with Learning Example, Particles
Page Index Toggle Pages: 1
Problem with Learning Example, Particles (Read 572 times)
Problem with Learning Example, Particles
May 15th, 2009, 10:16pm
 
Hello, i tried to work on some examples by dan Shiffman to understand them but i have some problem with this  Code : http://processing.org/learning/topics/simpleparticlesystem.html
Could somebody tell me where exactly the amout of particles is insert? there is a "num" but changes dont effekt anything. I just get alot of them at first but after that the amout is still the same. I dont get it...
Could you explain it to me?
Thank you!
Re: Problem with Learning Example, Particles
Reply #1 - May 16th, 2009, 1:19am
 
Because

for (int i = 0; i < num; i++) {
  particles.add(new Particle(origin));
}

happens within the ParticleSystem construction, it only happens once (during setup, when constructed).

Try putting this into draw() instead:

for (int i = 0; i < 20; i++) {
  ps.addParticle(mouseX,mouseY);
}

--Ben
Re: Problem with Learning Example, Particles
Reply #2 - May 23rd, 2009, 6:25pm
 
actually it would be slightly different because Particle expects a PVector in it's constructor.

So it would be more like

Code:

for (int i = 0; i < 20; i++) {
 ps.addParticle(new PVector(mouseX,mouseY));
}


but Ben had the right idea.

-adam
Page Index Toggle Pages: 1