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 › My Class is not reconised as a Type
Page Index Toggle Pages: 1
My Class is not reconised as a Type (Read 362 times)
My Class is not reconised as a Type
Sep 9th, 2008, 1:17am
 
I want to create a two dimensional array and fill it with my 'Tile' objects. Code:


size (200, 200);
background (0);
Tile[][] mosaic;
mosaic= new Tile[width][height];
for (int i= 0; i<width; i+=2){
 for (int j=0; j<height; j+=2){
 mosaic [i][j] = new Tile(i, j);
 }
}

class Tile
{
color colour = color(255);
int x;
int y;
Tile(int x,int y){
this.x = x;
this.y = y;
stroke(colour);
point(x, y);
}
void setColour(int i){
colour = i;}
int getColour(){
return colour.get();
}
}


However i get the error:

Semantic error: Type "Tile" was not found.

Can you help me get this to work please?
regards
Tim
Re: My Class is not reconised as a Type
Reply #1 - Sep 9th, 2008, 1:31am
 
You can't use classes and Processing Basic mode.
try:

Code:
Tile[][] mosaic;

void setup()
{
size (200, 200);
background (0);
}

void draw()
{
mosaic= new Tile[width][height];
for (int i= 0; i<width; i+=2){
for (int j=0; j<height; j+=2){
mosaic [i][j] = new Tile(i, j);
}
}
}

class Tile
{
color colour = color(255);
int x;
int y;
Tile(int x,int y){
this.x = x;
this.y = y;
stroke(colour);
point(x, y);
}
void setColour(int i){
colour = i;}
int getColour(){
return colour.get();
}
}
Re: My Class is not reconised as a Type
Reply #2 - Sep 9th, 2008, 8:59am
 
Thanks JohnG that works a charm!
Page Index Toggle Pages: 1