cp5 used in classes or how to get a multi-windowed sketch
in
Contributed Library Questions
•
2 months ago
Hey!
This is my first post here, so far - thank you for this wonderful community! I do tend to spend a lot of time here and find a lot of the answers around :) However, I seem to have troubles finding the answer of this specific question, and with my thesis submission knocking on the door I'm getting kinda desperate :)
Here it goes:
I am trying to get a few sketches stick together into a linear flow style application. The way I imagine it is the following:
- First screen_first;
- Second screen_second;
- int stage = 0;
- void setup()
- {
- size(860, 600);
- colorMode(HSB, 360, 100, 100);
- smooth();
- screen_first = new First();
- screen_second = new Second();
- }
- void draw()
- {
- background(0);
- switch(stage)
- {
- case 0:
- screen_first.draw();
- break;
- case 1:
- screen_second.draw();
- break;
- }
- }
- void mousePressed()
- {
- stage++;
- if (stage == 2) stage = 0;
- }
- class First
- {
- First()
- {
- size(860, 600);
- colorMode(HSB, 360, 100, 100);
- smooth();
- }
- void draw()
- {
- background(240, 40, 40);
- fill(300,100,90);
- rect(20,20,100,100);
- }
- }
- class Second
- {
- Second()
- {
- size(860, 600);
- colorMode(HSB, 360, 100, 100);
- smooth();
- }
- void draw()
- {
- background(50, 80, 40);
- fill(100,90,90);
- rect(50,120,200,200);
- }
- }
If I am conceptually wrong about this, please do advise me to what a better workflow might be.
Thank you in advance!
Deyan
1