We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello ! I'm doing a game and i got the error "cannot find a class or type named myclass". I tried to fix it but I don't understand where the problem is... If someone could help me it would be fine :) ! There is my code (only the 1st and 2nd tab ) :
//MAIN TAB
import ddf.minim.*;
import ddf.minim.analysis.*;
//création des objet appelant les fonctions minim
Minim minim;
AudioPlayer[]song;
BeatDetect beat;
Bouton Bouton1;
Bouton Bouton2;
BoutonG BoutonG1;
BoutonG BoutonG2;
BoutonG BoutonG3;
BoutonG BoutonG4;
BoutonM BoutonM1;
BoutonM BoutonM2;
BoutonM BoutonM3;
BoutonM BoutonM4;
BoutonM BoutonM5;
//bg est l'image de fond, bc l'image de la barre de chargement
PImage bg;
PImage bc;
PImage imagemenu;
PImage imagemenuM;
PFont titre;
PFont policescore;
int start;
//couleurs du jaune au rose
color from = color (136,6,206);
color to = color (38,196,236);
//variables
int i;
int j = 0;
int a = 1;
int b = 1;
ArrayList Obst;
int Debut;
int Temps;
int stage = 1;
int Bonus;
void setup() {
size (displayWidth, displayHeight-75); // Définit la taille de la fenêtre avec un enlevement de la barre de tâche
fill(0, 0, 0);
rect(0, 0, displayWidth, displayHeight-75);
song = new AudioPlayer[5];
Obst = new ArrayList();
minim = new Minim(this); //création d'un nouvel objet de classe "Minim"
//ArrayList Obst = new ArrayList ();
quad(45.75/100*width, 90, 49.51/100*width, 90, 36.6/100*width, height, 15.0/100*width, height); // Taille du chemin à gauche // (xHG, yHG, xHD, yHD, xBD, yBD, xBG, yBG)
quad(49.51/100*width, 90, 52.27/100*width, 90, 63.2/100*width, height, 36.6/100*width, height); // Taille du chemain au centre // Avec H = Haut, B = Bas
quad(52.27/100*width, 90, 56.03/100*width, 90, 84.8/100*width, height, 63.2/100*width, height); // Taille du chemin à droite // Avec D = Droite, G = Gauche
//l'objet song appelle la fonction minim.loadFile qui appelle, télécharge la musique dans le programme
song[0] = minim.loadFile("Musiques/305.mp3", 2048);
song[1] = minim.loadFile("Musiques/South Side.mp3", 2048);
song[2] = minim.loadFile("Musiques/Nightcore - Flute.mp3", 2048);
song[3] = minim.loadFile("Nightcore - Dam Dadi Do.mp3", 2048);
song[4] = minim.loadFile("Musiques/Quintino - Winner.mp3", 2048);
song[5] = minim.loadFile("Musiques/chauffeleshaakermod.mp3", 2048);
//l'objet beat appelle un objet de classe BeatDetect
beat = new BeatDetect();
//crée les polices
policescore = createFont("Arial Black", 32);
titre = createFont("Arial Black", 32);
//assigne la police crée ci-dessus aux caractères du score
textFont(policescore,25);
bg = loadImage("Images/Fond d'écran/image fond.jpg");
bc = loadImage("Images/Barre de chargement/barre de chargement 2.0.jpg");
imagemenu = loadImage("Images/Fond d'écran/Melow dash menu.jpg");
imagemenuM = loadImage("Images/Fond d'écran/m wpper.jpg");
image(bg,0,0);
start = millis();
titre = createFont("Arial Black", 32);
Bouton Bouton1 = new Bouton(1);
Bouton Bouton2 = new Bouton(2);
BoutonG BoutonG1 = new BoutonG(1);
BoutonG BoutonG2 = new BoutonG(2);
BoutonG BoutonG3 = new BoutonG(3);
BoutonG BoutonG4 = new BoutonG(4);
BoutonM BoutonM1 = new BoutonM(1);
BoutonM BoutonM2 = new BoutonM(2);
BoutonM BoutonM3 = new BoutonM(3);
BoutonM BoutonM4 = new BoutonM(4);
BoutonM BoutonM5 = new BoutonM(5);
BoutonM BoutonM6 = new BoutonM(6);
Score Mon_Score = new Score();
}
void draw() {
if(stage == 1){
fill(255,255,255);
textAlign(CENTER);
image(imagemenu,0,0);
image(imagemenuM,displayWidth/2-180,50);
text("Melow Dash",displayWidth/2,(displayHeight-75)/2);
Bouton1.draw();
}
if(stage == 4){
fill(255,255,255);
textAlign(CENTER);
image(imagemenu,0,0);
image(imagemenuM,displayWidth/2-180,50);
text("Choissisez votre musique",displayWidth/2,(displayHeight-75)/2);
BoutonM1.draw();
BoutonM2.draw();
}
if(stage == 8){
fill(255,255,255);
textAlign(CENTER);
image(imagemenu,0,0);
image(imagemenuM,displayWidth/2-180,50);
text("Choissisez votre DJ",displayWidth/2,(displayHeight-75)/2);
BoutonG1.draw();
BoutonG2.draw();
BoutonG3.draw();
BoutonG4.draw();
}
if(stage == 9){
fill(255,255,255);
textAlign(CENTER);
image(imagemenu,0,0);
image(imagemenuM,displayWidth/2-180,50);
text("Choissisez votre musique",displayWidth/2,(displayHeight-75)/2);
BoutonM3.draw();
BoutonM4.draw();
}
if(stage == 10){
fill(255,255,255);
textAlign(CENTER);
image(imagemenu,0,0);
image(imagemenuM,displayWidth/2-180,50);
text("Choissisez votre musique",displayWidth/2,(displayHeight-75)/2);
BoutonM5.draw();
}
if(stage == 11){
fill(255,255,255);
textAlign(CENTER);
image(imagemenu,0,0);
image(imagemenuM,displayWidth/2-180,50);
text("Choissisez votre musique",displayWidth/2,(displayHeight-75)/2);
BoutonM6.draw();
}
if(stage == 2){
//Score.affiche();
//Lance la musique
song[0].play();
imageMode(CORNER);
image(bg,0,0);
image(bc,50,50);
float songPos = song[0].position ();
float songLen = song[0].length ();
float xpos = (songPos / songLen) * 345;
if(songLen - songPos <= 500){
stage = 3;
}
noStroke();
for (int i=1;i<j;i+=15) {
color interA=lerpColor(from, to, (float(i)/360));
fill(interA);
rect(59, 60,xpos, 37);
}
Debut = millis();
//Lancement du processus de détection par la fonction beat.detect
beat.detect(song[0].mix);
//la fonction beat.isOnset "traque" le rythme en fonction de l'énergie générée par le son
if ( beat.isOnset() && Debut >= Temps+200 ) {
if (Bonus == 50) Bonus = 0;
Bonus = Bonus +1;
Obst.add(new Obstacles()); // http://stackoverflow.com/questions/5766698/how-to-cast-an-arraylist-of-objects-to-float-in-processing
Temps = Debut;
a = 0;
}
if (a == 0){
println(Bonus);
fill (255, 255, 255);
stroke (0);
quad(45.75/100*width, 90, 49.51/100*width, 90, 36.6/100*width,height, 15.0/100*width,height); // Taille du chemin à gauche // (xHG, yHG, xHD, yHD, xBD, yBD, xBG, yBG)
quad(49.51/100*width, 90, 52.27/100*width, 90, 63.2/100*width,height, 36.6/100*width,height); // Taille du chemain au centre // Avec H = Haut, B = Bas
quad(52.27/100*width, 90, 56.03/100*width, 90, 84.8/100*width,height, 63.2/100*width,height); // Taille du chemin à droite // Avec D = Droite, G = Gauche
for (int i = Obst.size()-1; i >= 0; i--) {
Obstacles obst = (Obstacles) Obst.get(i);
obst.deplacement(int(Bonus/50));
}
}
if (j<360) j++;
}
if(stage == 5){
//Score.affiche();
//Lance la musique
song[1].play();
imageMode(CORNER);
image(bg,0,0);
image(bc,50,50);
float songPos = song[1].position ();
float songLen = song[1].length ();
float xpos = (songPos / songLen) * 345;
if(songLen - songPos <= 500){
stage = 3;
}
noStroke();
for (int i=1;i<j;i+=15) {
color interA=lerpColor(from, to, (float(i)/360));
fill(interA);
rect(59, 60,xpos, 37);
}
Debut = millis();
//Lancement du processus de détection par la fonction beat.detect
beat.detect(song[1].mix);
//la fonction beat.isOnset "traque" le rythme en fonction de l'énergie générée par le son
if ( beat.isOnset() && Debut >= Temps+200 ) {
if (Bonus == 50) Bonus = 0;
Bonus = Bonus +1;
Obst.add(new Obstacles()); // http://stackoverflow.com/questions/5766698/how-to-cast-an-arraylist-of-objects-to-float-in-processing
Temps = Debut;
a = 0;
}
if (a == 0){
println(Bonus);
fill (255, 255, 255);
stroke (0);
quad(45.75/100*width, 90, 49.51/100*width, 90, 36.6/100*width,height, 15.0/100*width,height); // Taille du chemin à gauche // (xHG, yHG, xHD, yHD, xBD, yBD, xBG, yBG)
quad(49.51/100*width, 90, 52.27/100*width, 90, 63.2/100*width,height, 36.6/100*width,height); // Taille du chemain au centre // Avec H = Haut, B = Bas
quad(52.27/100*width, 90, 56.03/100*width, 90, 84.8/100*width,height, 63.2/100*width,height); // Taille du chemin à droite // Avec D = Droite, G = Gauche
for (int i = Obst.size()-1; i >= 0; i--) {
Obstacles obst = (Obstacles) Obst.get(i);
obst.deplacement(int(Bonus/50));
}
}
if (j<360) j++;
}
if(stage == 6){
//Score.affiche();
//Lance la musique
song[2].play();
imageMode(CORNER);
image(bg,0,0);
image(bc,50,50);
float songPos = song[2].position ();
float songLen = song[2].length ();
float xpos = (songPos / songLen) * 345;
if(songLen - songPos <= 500){
stage = 3;
}
noStroke();
for (int i=1;i<j;i+=15) {
color interA=lerpColor(from, to, (float(i)/360));
fill(interA);
rect(59, 60,xpos, 37);
}
Debut = millis();
//Lancement du processus de détection par la fonction beat.detect
beat.detect(song[2].mix);
//la fonction beat.isOnset "traque" le rythme en fonction de l'énergie générée par le son
if ( beat.isOnset() && Debut >= Temps+200 ) {
if (Bonus == 50) Bonus = 0;
Bonus = Bonus +1;
Obst.add(new Obstacles()); // http://stackoverflow.com/questions/5766698/how-to-cast-an-arraylist-of-objects-to-float-in-processing
Temps = Debut;
a = 0;
}
if (a == 0){
println(Bonus);
fill (255, 255, 255);
stroke (0);
quad(45.75/100*width, 90, 49.51/100*width, 90, 36.6/100*width,height, 15.0/100*width,height); // Taille du chemin à gauche // (xHG, yHG, xHD, yHD, xBD, yBD, xBG, yBG)
quad(49.51/100*width, 90, 52.27/100*width, 90, 63.2/100*width,height, 36.6/100*width,height); // Taille du chemain au centre // Avec H = Haut, B = Bas
quad(52.27/100*width, 90, 56.03/100*width, 90, 84.8/100*width,height, 63.2/100*width,height); // Taille du chemin à droite // Avec D = Droite, G = Gauche
for (int i = Obst.size()-1; i >= 0; i--) {
Obstacles obst = (Obstacles) Obst.get(i);
obst.deplacement(int(Bonus/50));
}
}
if (j<360) j++;
}
if(stage == 7){
//Score.affiche();
//Lance la musique
song[3].play();
imageMode(CORNER);
image(bg,0,0);
image(bc,50,50);
float songPos = song[3].position ();
float songLen = song[3].length ();
float xpos = (songPos / songLen) * 345;
if(songLen - songPos <= 500){
stage = 3;
}
noStroke();
for (int i=1;i<j;i+=15) {
color interA=lerpColor(from, to, (float(i)/360));
fill(interA);
rect(59, 60,xpos, 37);
}
Debut = millis();
//Lancement du processus de détection par la fonction beat.detect
beat.detect(song[3].mix);
//la fonction beat.isOnset "traque" le rythme en fonction de l'énergie générée par le son
if ( beat.isOnset() && Debut >= Temps+200 ) {
if (Bonus == 50) Bonus = 0;
Bonus = Bonus +1;
Obst.add(new Obstacles()); // http://stackoverflow.com/questions/5766698/how-to-cast-an-arraylist-of-objects-to-float-in-processing
Temps = Debut;
a = 0;
}
if (a == 0){
println(Bonus);
fill (255, 255, 255);
stroke (0);
quad(45.75/100*width, 90, 49.51/100*width, 90, 36.6/100*width,height, 15.0/100*width,height); // Taille du chemin à gauche // (xHG, yHG, xHD, yHD, xBD, yBD, xBG, yBG)
quad(49.51/100*width, 90, 52.27/100*width, 90, 63.2/100*width,height, 36.6/100*width,height); // Taille du chemain au centre // Avec H = Haut, B = Bas
quad(52.27/100*width, 90, 56.03/100*width, 90, 84.8/100*width,height, 63.2/100*width,height); // Taille du chemin à droite // Avec D = Droite, G = Gauche
for (int i = Obst.size()-1; i >= 0; i--) {
Obstacles obst = (Obstacles) Obst.get(i);
obst.deplacement(int(Bonus/50));
}
}
if (j<360) j++;
}
if(stage == 12){
//Score.affiche();
//Lance la musique
song[4].play();
imageMode(CORNER);
image(bg,0,0);
image(bc,50,50);
float songPos = song[4].position ();
float songLen = song[4].length ();
float xpos = (songPos / songLen) * 345;
if(songLen - songPos <= 500){
stage = 3;
}
noStroke();
for (int i=1;i<j;i+=15) {
color interA=lerpColor(from, to, (float(i)/360));
fill(interA);
rect(59, 60,xpos, 37);
}
Debut = millis();
//Lancement du processus de détection par la fonction beat.detect
beat.detect(song[4].mix);
//la fonction beat.isOnset "traque" le rythme en fonction de l'énergie générée par le son
if ( beat.isOnset() && Debut >= Temps+200 ) {
if (Bonus == 50) Bonus = 0;
Bonus = Bonus +1;
Obst.add(new Obstacles()); // http://stackoverflow.com/questions/5766698/how-to-cast-an-arraylist-of-objects-to-float-in-processing
Temps = Debut;
a = 0;
}
if (a == 0){
println(Bonus);
fill (255, 255, 255);
stroke (0);
quad(45.75/100*width, 90, 49.51/100*width, 90, 36.6/100*width,height, 15.0/100*width,height); // Taille du chemin à gauche // (xHG, yHG, xHD, yHD, xBD, yBD, xBG, yBG)
quad(49.51/100*width, 90, 52.27/100*width, 90, 63.2/100*width,height, 36.6/100*width,height); // Taille du chemain au centre // Avec H = Haut, B = Bas
quad(52.27/100*width, 90, 56.03/100*width, 90, 84.8/100*width,height, 63.2/100*width,height); // Taille du chemin à droite // Avec D = Droite, G = Gauche
for (int i = Obst.size()-1; i >= 0; i--) {
Obstacles obst = (Obstacles) Obst.get(i);
obst.deplacement(int(Bonus/50));
}
}
if (j<360) j++;
}
if(stage == 13){
//Score.affiche();
//Lance la musique
song[5].play();
imageMode(CORNER);
image(bg,0,0);
image(bc,50,50);
float songPos = song[5].position ();
float songLen = song[5].length ();
float xpos = (songPos / songLen) * 345;
if(songLen - songPos <= 500){
stage = 3;
}
noStroke();
for (int i=1;i<j;i+=15) {
color interA=lerpColor(from, to, (float(i)/360));
fill(interA);
rect(59, 60,xpos, 37);
}
Debut = millis();
//Lancement du processus de détection par la fonction beat.detect
beat.detect(song[5].mix);
//la fonction beat.isOnset "traque" le rythme en fonction de l'énergie générée par le son
if ( beat.isOnset() && Debut >= Temps+200 ) {
if (Bonus == 50) Bonus = 0;
Bonus = Bonus +1;
Obst.add(new Obstacles()); // http://stackoverflow.com/questions/5766698/how-to-cast-an-arraylist-of-objects-to-float-in-processing
Temps = Debut;
a = 0;
}
if (a == 0){
println(Bonus);
fill (255, 255, 255);
stroke (0);
quad(45.75/100*width, 90, 49.51/100*width, 90, 36.6/100*width,height, 15.0/100*width,height); // Taille du chemin à gauche // (xHG, yHG, xHD, yHD, xBD, yBD, xBG, yBG)
quad(49.51/100*width, 90, 52.27/100*width, 90, 63.2/100*width,height, 36.6/100*width,height); // Taille du chemain au centre // Avec H = Haut, B = Bas
quad(52.27/100*width, 90, 56.03/100*width, 90, 84.8/100*width,height, 63.2/100*width,height); // Taille du chemin à droite // Avec D = Droite, G = Gauche
for (int i = Obst.size()-1; i >= 0; i--) {
Obstacles obst = (Obstacles) Obst.get(i);
obst.deplacement(int(Bonus/50));
}
}
if (j<360) j++;
}
if(stage == 3){
fill(255,255,255);
imageMode(CORNER);
textAlign(CENTER);
image(imagemenu,0,0);
textFont(titre,50);
text("Score",displayWidth/2,(displayHeight-75)/2-200);
textFont(policescore,25);
Bouton2.draw();
}
}
void mousePressed() {
Bouton1.mousePressed();
Bouton2.mousePressed();
BoutonM1.mousePressed();
BoutonM2.mousePressed();
BoutonM3.mousePressed();
BoutonM4.mousePressed();
BoutonM5.mousePressed();
BoutonM6.mousePressed();
BoutonG1.mousePressed();
BoutonG2.mousePressed();
BoutonG3.mousePressed();
BoutonG4.mousePressed();
}
//TAB 2
class Bouton {
boolean rectOver = false;
int rectX;
int rectY;
color rectColor;
color rectHighlight;
Bouton(int A){
rectColor = color(136,6,206);
rectHighlight = color(38,196,236);
rectX = displayWidth/2-150;
rectY = (displayHeight-75)/2+25;
}
void draw() {
update(mouseX, mouseY);
if (rectOver == true) {
fill(rectHighlight);
}
else {
fill(rectColor);
}
stroke(255);
rect(rectX, rectY, 300, 50);
fill(255,255,255);
if(stage == 1){
text("Jouer",displayWidth/2,(displayHeight-75)/2+60);
}
if(stage == 3){
text("Retour",displayWidth/2,(displayHeight-75)/2+60);
}
}
void update(int x, int y) {
if ( overRect(rectX, rectY, 300, 50) ) {
rectOver = true;
}
else {
rectOver = false;
}
}
void mousePressed() {
if (rectOver) {
if( A == 1){
stage = 8;
}
if( A == 2){
stage = 1;
}
}
}
boolean overRect(int x, int y, int width, int height) {
if (mouseX >= x && mouseX <= x+width &&
mouseY >= y && mouseY
Answers
Hi, if you could, please, properly format the code, it would be much easier to try... :)
http://forum.processing.org/two/discussion/8045/how-to-format-code-and-text#latest
ty for the link, now it's readable ^^
err... the word myclass doesn't occur
please post the tab where myclass occurs and the the tab where you get the error
please tell in which line in which tab you get the error
probably a spelling mistake like myclass versus Myclass or
myClass versus myclass
make sure you write it all the same (it's case-sensitive).
Also, the name is not very strong anyway... ;-)
;-)
the error occur line 9 : "cannot find a class or type named BoutonG" and it may comes from tab 2 where the class is defined
and can you post class BoutonG?
it's named class Bouton, not class BoutonG
sry that's the rigth class
ok, there must be only one class BoutonG
not two with the same name
you have
Bouton
BoutonM
and BoutonG
?
by the way : all the lines
Bouton Bouton1 = new Bouton(1);
like this insetup()
are probabaly wrongyou want
without the type / class before it I guess.
Otherwise they have local scope only in setup() and not global scope (as you defined them before
setup()
).;-)
yeah but even when i changed from
to
I keep having the class name error
this looks correct:
as said, when you use the class names
Bouton
BoutonG
and
BoutonM
they must bew written like in the class definition
and also, no 2 class definitions allowed with the same name
read your code carefully...
show BoutonM please
also use ctrl-t in processing and check whether all { and } are correct or if you place one class in another class.....
this part is not complete
boolean overRectm(int x, int y, int width, int height) { if (mouseX >= x && mouseX <= x+width && mouseY >= y && mouseY
also I think in
class BoutonM {
the last } comes too early
it must come after the function overRectm
not before
I think this is causing the problems: the misplaced }
why do you not just int {myClass}?
what do you mean?
Please when using
<pre></pre>
for Processing, correct syntax is:<pre lang=processing>
, OK? ;;)Also, even before posting your code, inside Processing's Editor (PDE), apply CTRL+T in order to correct indent it! *-:)