I made a sketch containing many files. Everything worked fine, until I wrote the following function:
int[] get_faller_times(int level_in, int stage_in) {
int[] faller_ts;
if (level_in == 1 && stage_in == 1) {
faller_ts = {
220,
380,
400, 450,
510, 530,
600, 600, 600, 600, 650, 680,
800, 820, 840, 860, 880,
900, 910, 920, 930, 940, 950, 960, 970, 980, 990,
1450, 1450,
1550, 1550,
1630, 1660, 1690,
1720, 1750, 1770, 1790,
1850, 1850, 1850, 1850, 1850, 1850,
1900, 1910, 1920, 1950, 1960, 1970,
2050, 2060, 2070,
2100, 2110, 2120,
2200, 2200, 2200, 2200, 2200, 2200
};
}
else {
faller_ts = {
};
}
return faller_ts;
}
When trying to run the sketch, Processing threw an error:
unexpected token: {
pointing to the closing '}' on the last line of a
different file in the sketch.
Strange thing is, the error persists even when I undo all the changes. No matter what I do, I can't get rid of the error.
I also didn't find this in the forum.... sorry if this is known already. I'm fairly new to Processing -.-
edit: even when I copy-paste all the code to a different Processing instance, creating tabs as necessary and save the project with a new name, the error reappears.
I'm new to the forum and relatively new to processing, just starting to get a bit more serious with it. I didn't know any Java before.
I'm getting a "Cannot find anything named "token" when running my sketch, and I can't figure it out by myself, so please help. I should say that I don't expect the sketch to run right now, as I didn't implement all class methods - I'm rather doing a show-me-whats-the-next-problem-style debugging approach to constructing the program.
What I have is a class (in a different file as setup() and draw() are, but I guess that shouldn't be a problem?):
class Token {
float life;
Token () {
println("token creator");
life = 30;
}
void display() {
stroke(30, 100, 100);
strokeWeight(3);
fill(30, 60, 100);
ellipse(mouseX, height-height/10, 10, 10);
}
}
Then, in my setup() function, I say
Token token = new Token();
which works as far as I can see. However, in draw(), when the line
token.display();
gets read by Processing, it throws the error:
Cannot find anything named "token"
I'm clueless, since I thought I created "token" in setup(). Any clues?