I’m new here and I already have a question. I searched on the internet and didn’t find an answer, so I hope you’ll help please understand some things !
I created my first app, based on the tutorials, but there’s something I find weird about the draw() function.
It’s a loop function, like on Processing, Arduino, etc.
But if you create a circle in the draw function, and update it’s coordinates x and y, the circle moves.
Why doesn’t it create a new circle with the new positions ? Why does it think that it’s the same circle ?
How can I generate a new circle on every position ? Like x+10, y+10 ?
Is this about classes ? Do I have to create a general circle class and create a new object for new circles ?
Thanks for you answers, I’m trying to understand what happens inside the function.
When the draw function is done, your screen is cleared, this means in the next loop you need to draw everything again.
If you want to have several circles you should call ofCircle as many times as circles you want in the same drawing loop, and for that you need to store the positions (in a vector for instance).
This doesn’t relate to classes directly. It does not matter whether you have a circle class or not. Notice ofCircle doesn’t create circle objects, it just draws a circle.
Probably you want to draw them on a ofFbo, check the fboTrailsExample. Or the alphaMaskingShaderExample. They both draw stuff in this Frame Buffer Object, think of it as another screen, except this one won’t get cleared unless you explicitely clear it.
You can then draw circles on click or whenever you want, and render them onto this FBO.