I working on a simple program as a part of a sound-reactive installation. Every time the sound velocity is more than 5, a rectangle comes in on the right, and all other objects shift one place to the left.
The problem: the velocity is the width/height of the rectangles. Now it affects all objects, but I only want to assign the value to the newest, so all rectangles get their own size (and stay that size). Maybe there is something wrong with void show() and I tried things with an arraylist, but I'm afraid I'm a bit lost.
This is a simplified example to make it more clear, in the real version the rectangles are characters (kind of sound-reactive newsticker).
If anyone can point me in the right direction, that would be great :-)
The problem is that you are using vel to display all of the rectangles. If you want the rectangles to be size-independent, then you need to make a size value for each of the rectangles (that is, inside the Rectangle class... probably assigned when the value is received and the rectangle is created).
In setup() I create al rectangles ( myRectangle[i] = new Rectangle(10); ). I show them with display() in draw. And change the xpos in update();
But I can't assign the value in setup(), because there isn't sound yet in setup. That's why I wanted to assign the sound value with display().
Maybe I need to create the rectangles with an arraylist, so I can create them in the draw? I've tried this already, but maybe in a wrong way.
Oh, and this what I am trying to do: I simplified it to rectangles, but in the end it will be characters consisting of rectangles with a different size for every character (the code to import text and create the characters out of rectangles works already, but isn't relevant for this problem).