I’m having trouble making graphics objects after the sketch is already running. Is this not something I’m supposed to be able to do?
In this sketch, you can press the spacebar to create a blue square or you can press the A key to create a red one. You can press the same key again to destroy that square.
What I’m doing here is creating a graphics object on the first press of each of those keys and then calling the
remove method on it. If you press it again, it creates another one and stores it in the same place the first one was stored in. It seems at first glace that it’s not making any subsequent squares after the first one you make, but actually, it does still create the graphics object and add it to the HTML, it’s just that subsequent drawing to it doesn’t seem to work anymore.
Am I doing something wrong? Considering that p5.Graphics doesn’t have a resize method, I figured destroying it and creating a new one was the only way to resize it, and I want to be able to do that in a project.