Animate number of particles through GUI

edited January 2016 in Library Questions

Hi there - I have a program which creates particles and has them floating on screen. What I would like to do is update the number of created particles through a slider in the GUI. I've tried a few things but I can't get it to work, I got it to work once but a new particle system was created every frame so not too useful..

If you have any ideas or places I could look it would be greatly appreciated!

Thanks

Tagged:

Answers

  • you should post your code or a mcve of your code

    http://stackoverflow.com/help/mcve

    anyway, maybe you want to look here:

    http://www.openprocessing.org/sketch/52558

    (I guess it's for processing 1 / 2)

  • I got it to work once but a new particle system was created every frame so not too useful..

    that doesn't sound to good

    actually, you should start the particle system in setup() and then run it in draw()

    so in draw read the values from the sliders (or read the values in the event functions, store them in a global var and that var gets used by draw())

  • Hi Chrisir, thanks for the comments!

    I've uploaded the sketch here, name of sketch is "Sketch_02_GUI". There are some classes in there also.

    I can control the threshold for when points are connected but not the number of particles in the running sketch. What would you recommend? - Thanks!

  • well, compare the number of the particles with the number the GUI gives you

    then either append items p or remove items

    this would be easier if p were an ArrayList but never mind

    look at

    https://www.processing.org/reference/append_.html

    and

    https://www.processing.org/reference/shorten_.html

    for append iirc

    LimitedParticle element = new LimitedParticle (...........................); 
    LimitedParticle[] p= (LimitedParticle[]) append(p, element); 
    
Sign In or Register to comment.