I have created 4 different function blocks. Is there a way to have one function run for 3 seconds, and then switch to the next function for 3 seconds, etc, etc? when I put them all in the draw block, they all overlap so I need some sort of delay between functions.
Thank you so so much! If I wanted to add a “if key pressed…freeze this function and start new function”, would you happen to know how to do that? each function is just a drawing of shapes. I just want the shape to stay when key pressed, and then start new function where shape can stay when key pressed.
Hmm, maybe I am describing my issue poorly…I don’t think the above code would work in my case.
I have 4 different functions I want to run. Each function will cycle through 3 different shapes continuously until a key is pressed and released. When the key is pressed and released, whatever shape is on the screen will stay on the screen until the very end and the next function block will run. The next function block will also cycle through 3 other different shapes. Again, when key is pressed and released, whatever shape is on the screen will stay (there would be 2 shapes stuck on the screen now), etc, etc. So basically need to freeze a function, skip the rest of the block and start a new function when the key is pressed and released. It can be any key.
So I have the function displaying for some seconds and then switching to the next shape by using mills:
int m = (milliseconds()/1000)%10;
void shapesCategory1()
{
if (m < 3)
{
drawCircle();
}
if (m < 6)
{
drawSquare();
}
if (m < 9)
{
drawRectangle();
}
the only way I know how to stop this Is by saying:
boolean keySelect;
keySelect = false; (this is under void setup)
void keyPressed()
{
keySelect = !keySelect;
}
and then under each draw shape add:
if (keySelect)
{
drawCircle();
noLoop();
}
but then it just stops completely. Is there a function similar to noLoop() that will let me jump to a different function block when key is pressed so that I can select the next set of shapes in another function?
I would paste my code but it is SO messy and barely makes any sense to me right now lol