value returning keypressed() not working
              in 
             Programming Questions 
              •  
              7 months ago    
            
 
           
             I'm tiring to retrieve a Boolean value after the space bar is pushed.I believe i'm doing it right but when I try to run it outputs "unexpected token : boolean"
            
            
             /**
            
            
              * PhotoBoothV2.pde
            
            
              */
            
            
             import processing.video.*;
            
            
             boolean sketchFullScreen() {
            
            
               return true;
            
            
             }
            
            
             // resolution: 800x600 - change it if you want
            
            
             //Crap
            
            
             //int cols = 320;
            
            
             //int rows = 240  ; 
            
            
             //720p
            
            
             //int cols = 1280;
            
            
             //int rows = 720 ; 
            
            
             //1080p
            
            
             int cols = 1920;
            
            
             int rows =1080; 
            
            
             Capture cam;
            
            
             int mainwidth  = cols;
            
            
             int mainheight = rows;
            
            
             PImage img1;
            
            
             PImage img2;
            
            
             PImage img3;
            
            
             PImage img4;
            
            
             int time5 = 70;
            
            
             int time4 = 60;
            
            
             int time3 = 50;
            
            
             int time2 = 40;
            
            
             int time1 = 30;
            
            
             int x = 1;
            
            
             boolean countDown ;
            
            
             PFont font;
            
            
             String number;
            
            
             long starttime;
            
            
             long time;
            
            
             //PImage img2;
            
            
             void setup() {
            
            
               size(1600, 900);
            
            
               frameRate(30);
            
            
               //size(mainwidth, mainheight, JAVA2D);
            
            
               //size(1600,900);
            
            
               colorMode(RGB);
            
            
               cam = new Capture(this, cols, rows);
            
            
               cam.start();
            
            
               noSmooth();
            
            
               background(51);
            
            
               font = loadFont("AgencyFB-Bold-200.vlw");
            
            
               textFont(font);
            
            
               number = " ";
            
            
               countDown = false;
            
            
             }
            
            
             void draw() {
            
            
               if (cam.available()) {
            
            
                 cam.read();
            
            
                 image(cam, 0, 0, 320, 240);
            
            
                 fill(RGB);
            
            
                 fill(255, 0, 0);
            
            
                 text(number, 100, 100);
            
            
                 if (countDown == true)  
            
            
                 {
            
            
                   while ( (time - starttime) >= 5000)
            
            
                   {
            
            
                     image(cam, 0, 0, 320, 240);
            
            
                     time = millis();
            
            
                     if ((time -starttime) >= 1000)
            
            
                     {
            
            
                       number = "5";
            
            
                     } 
            
            
                     if ((time -starttime) >= 2000)
            
            
                     {
            
            
                       number ="4";
            
            
                     }
            
            
                     if ((time -starttime) >= 3000)
            
            
                     {
            
            
                       number= "3";
            
            
                     }
            
            
                     if ((time -starttime) >= 4000)
            
            
                     {
            
            
                       number = "2";
            
            
                     } 
            
            
                     if ((time -starttime) >= 5000)
            
            
                     { 
            
            
                       number = "1";
            
            
                     }
            
            
                     countDown = false;
            
            
                   }
            
            
                 }
            
            
                 save("temp/temp1.jpg");
            
            
                 cam.save("temp/temp1.jpg");
            
            
               } 
            
            
               boolean keyPressed() {
            
            
                 if (key == ' ') {  // space bar
            
            
                   textSize(200);
            
            
                   starttime = millis();
            
            
                   countDown = true ;
            
            
                   return countDown;
            
            
                 }
            
            
                 //  img1 =img.get();
            
            
                 // img1.save("picture-####.jpg");
            
            
                 // PImage img2 = createImage(320,240,RGB);
            
            
                 //img2.loadPixels();
            
            
                 //cam.stop();
            
            
                 //saveFrame("picture-####.jpg");
            
            
                 if (key == 'l') {
            
            
                   //cam.stop(); 
            
            
                   img1 = loadImage("temp/temp1.jpg");
            
            
                   image(img1, 0, 0 );
            
            
                   //image(img1, 0, 0);
            
            
                   //image(img2, 0, 0);
            
            
                 } 
            
            
                 if (key == 'q') {
            
            
                   exit();
            
            
                 }
            
            
               }   
            
             
              
              1  
            
 
            
 
 
           
 
            