Dans le code ci-dessous, j'essayais de créer un programme simple où vous cliquez simplement avec votre souris sur l'écran pour créer une autre balle qui rebondit autour. Je dis dans la console d'erreur que le constructeur n'existe pas sur la ligne où il y a la fonction mousePressed, je ne suis pas sûr de ce que l'erreur est, quelqu'un peut-il me dire ce qui ne va pas avec mon code?Le constructeur n'existe pas dans le traitement
Ball ball;
ArrayList<Ball> balls = new ArrayList<Ball>();
void setup() {
size (640, 360);
ball = new Ball();
ball.Setup();
}
void draw() {
background (55);
ball.show();
ball.update();
}
void mousePressed() {
balls.add(new Ball(mouseX, mouseY));
}
class Ball{
float a;
float b;
float movex;
float speedx;
float movey;
float speedy;
int fcolor;
void Setup(){
fcolor = 255;
a = random (-6, 6);
speedx = width/2;
b = random (6, -6);
speedy= height/2;
if (a < 0) {
movex = -6;
} else {
movex = 6;
}
if (b < 0) {
movey = -6;
} else {
movey = 6;
}
}
void show(){
fill (fcolor);
stroke (fcolor);
ellipse (speedx, speedy, 50, 50);
}
void update() {
speedx = speedx + movex;
speedy = speedy + movey;
if (speedx > width) {
speedx = width;
movex = -movex;
fcolor = color(random(255),random(2,55),random(0,255));
}
if (speedx < 0) {
speedx = 0;
movex = -movex;
fcolor = color(random(0,255),random(0,255),random(0,255));
speedy = speedy + 0.2;
}
if (speedy > height) {
speedy = height;
movey = -movey;
fcolor = color(random(0,255),random(0,55),random(0,255));
}
if (speedy < 0) {
speedy = 0;
movey = -movey;
fcolor = color(random(0,255),random(0,255),random(0,255));
}
}
}
Merci pour la réponse et les commentaires. – Emilio