Loading...
Logo
Processing Forum
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:

Copy code
  1. First  screen_first;
  2. Second screen_second;
  3. int stage = 0;

  4. void setup()
  5. {
  6.   size(860, 600);
  7.   colorMode(HSB, 360, 100, 100);
  8.   smooth();
  9.   screen_first = new First();
  10.   screen_second = new Second();  
  11. }

  12. void draw()
  13. {
  14.   background(0);
  15.   switch(stage)
  16.   {
  17.   case 0:
  18.   screen_first.draw();
  19.   break;
  20.   case 1:
  21.   screen_second.draw();
  22.   break;
  23.   }
  24. }

  25. void mousePressed()
  26. {
  27.   stage++;
  28.   if (stage == 2) stage = 0;
  29. }

  30. class First 
  31. {
  32.   First()
  33.   {    
  34.     size(860, 600);
  35.     colorMode(HSB, 360, 100, 100);
  36.     smooth();
  37.   }

  38.   void draw()
  39.   {
  40.     background(240, 40, 40);
  41.     fill(300,100,90);
  42.     rect(20,20,100,100);
  43.   }  
  44. }

  45. class Second
  46. {
  47.   Second()
  48.   {
  49.     size(860, 600);
  50.     colorMode(HSB, 360, 100, 100);
  51.     smooth();
  52.   }
  53.   void draw()
  54.   {
  55.     background(50, 80, 40);
  56.     fill(100,90,90);
  57.     rect(50,120,200,200);
  58.   }
  59. }
Now, I did my research here first - there seems to be a lot of ways to accomplish the task using extra frames, but that's not what I would like to use if possible. The idea is that there is no main control screen,  but rather toggling (linearly switching to) 4 sketches (that I am working on separately right now). 

If I am conceptually wrong about this, please do advise me to what a better workflow might be. 

Thank you in advance!

Deyan