We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › sketch cannot find class
Page Index Toggle Pages: 1
sketch cannot find class (Read 535 times)
sketch cannot find class
Mar 18th, 2010, 11:08am
 
Hi,

I have a sketch which has an object called Die, which is then used in an array to store data about dice being used in a game.

The class structure looks fine, but the main sketch cannot see it, and I can not find my error.

import TUIO.*;
import themidibus.*; //Import the library
import javax.sound.midi.MidiMessage; //Import the MidiMessage class
Die[] dice;//Declare the array
TuioProcessing tuioClient; //Tuio client for reacTIVision
TuioObject tobj;//for Tuio
MidiBus myBus; // The MidiBus
int numdice = 10;
int i = 100;

void setup() {
 size(10,10);
 noStroke();
 }
void draw() {
 dice= new Die[numdice];
 TuioProcessing tuioClient = new TuioProcessing(this);
 myBus = new MidiBus(this,"IAC Bus 1","IAC Bus 1");// Create a new MidiBus object
 for (int i=0; i< dice.length; i++) {
   //load dice details into array???
   dice[i] = new Die(tobj.getSymbolID(), tobj.getX(), tobj.getY(), tobj.getAngle() );
 }
 for (i = 0; i < dice.length; i++) {
   dice[i].midisend();
 }
}
void addTuioObject(TuioObject tobj) {
 println("add object "+tobj.getSymbolID()+" ("+tobj.getSessionID()+ ") "+tobj.getX()+" "+tobj.getY()+" "+tobj.getAngle());
}
void removeTuioObject(TuioObject tobj) {
 println("remove object "+tobj.getSymbolID()+" ("+tobj.getSessionID()+")");
}
// called when an object is moved
void updateTuioObject (TuioObject tobj) {
 println("update object "+tobj.getSymbolID()+" ("+tobj.getSessionID()+") "+tobj.getX()+" "+tobj.getY()+" "+tobj.getAngle()
         +" "+tobj.getMotionSpeed()+" "+tobj.getRotationSpeed()+" "+tobj.getMotionAccel()+" "+tobj.getRotationAccel());
}
// called when a cursor is added to the scene
void addTuioCursor(TuioCursor tcur) {
 println("add cursor "+tcur.getCursorID()+" ("+tcur.getSessionID()+ ") " +tcur.getX()+" "+tcur.getY());
}
// called when a cursor is moved
void updateTuioCursor (TuioCursor tcur) {
 println("update cursor "+tcur.getCursorID()+" ("+tcur.getSessionID()+ ") " +tcur.getX()+" "+tcur.getY()
         +" "+tcur.getMotionSpeed()+" "+tcur.getMotionAccel());
}
// called when a cursor is removed from the scene
void removeTuioCursor(TuioCursor tcur) {
 println("remove cursor "+tcur.getCursorID()+" ("+tcur.getSessionID()+")");
}
// called after each message bundle
// representing the end of an image frame
void refresh(TuioTime bundleTime) {
 redraw();
 }
}

class Die {
 //properties
 float dieX, dieY, dieAngle;
 int dieface;
 Die(int dieface, float dieX, float dieY, float dieAngle) {
   this.dieface = dieface;
   this.dieX = dieX;
   this.dieY = dieY;
   this.dieAngle = dieAngle;
 }
 //methods
 void setdieface(int dieface) {
   this.dieface = dieface;
 }
 int getdieface() {
   return dieface;
 }
 void setdieX(float dieX) {
   this.dieX = dieX;
 }
 float getdieX() {
   return dieX;
 }
 void setdieY(float dieY) {
   this.dieY = dieY;
 }
 float getdieY() {
   return dieY;
 }
 void setdieAngle(float dieAngle) {
   this.dieAngle = dieAngle;
 }
 float getdieAngle() {
   return dieAngle;
 }
void midisend(){
 int channel = 0;
 int velocity = 99;
 myBus.sendNoteOn(channel, Die.getdieface(), velocity);
   //myBus.sendMessage(0xB0,0, getdieface(), velocity);//(0xB0 = continous ctllr,channel,pitch,velocity)
   //myBus.sendMessage(  
   }
 }
}

Thanks,
Russell
Re: sketch cannot find class
Reply #1 - Mar 18th, 2010, 11:13am
 
This is usually due to an extra curly bracket somewhere.... check them all....
Re: sketch cannot find class
Reply #2 - Mar 18th, 2010, 12:15pm
 
You have an extra closing brace after the refresh() function, and another after the Die class definition.
Proper indenting helps a lot with correct code.
Also remember that the PDE shows matching brace when clicking on one of a pair.
Page Index Toggle Pages: 1