今天我偶然发现了所有错误中最致命的错误。处理没有看到我的课程......我不知道为什么它没有,因为我对此很陌生。
这是我的主要课程:
Player thePlayer = new Player();
Guard theGuard = new Guard();
SpeedPWRUP speedPowerUp = new SpeedPWRUP();
Keyboard theKeyboard = new Keyboard();
void setup() {
size(1000, 500);
theGuard.init();
thePlayer.init();
speedPowerUp.init();
}
void updateGame() {
theGuard.update();
thePlayer.update();
speedPowerUp.update();
}
void drawGame() {
thePlayer.draw();
theGuard.draw();
speedPowerUp.draw();
fill(color(0, 0, 0));
text(("Score:"), 10, 20);
}
void draw() {
background(255);
fill (0, 0, 0);
rect(-10, 401, 1100, 100);
noFill();
updateGame();
drawGame();
Keyboard();
}
这是我的播放器类:
class Player {
public float playerX, playerY;
float vx, vy;
int fillColor;
float diameterPlayer;
float jumpTime;
float jumpHeight;
boolean isJumping;
float collisionGuard;
boolean speedUpActive;
boolean facingRight;
void init() {
diameterPlayer = 40;
fillColor = color(0, 0, 0);
jumpTime = 200;
jumpHeight = 100;
isJumping = false;
collisionGuard = 80;
speedUpActive = false;
facingRight = false;
playerX = 100;
playerY = 400-diameterPlayer;
vx = 0;
vy = 0;
}
void update() {
if(theKeyboard.holdingUp == true && isOnGround == true) {
vx = 5;
isOnGround = false;
}
if(theKeyboard.holdingDown == true) {
diameterPlayer = 40;
}
if(theKeyboard.holdingLeft == true) {
vx = -2;
}
if(theKeyboard.holdingRight == true) {
vx = 2;
}
if (playerY < (400-diameterPlayer/2)) {
vy = vy + 2.5;
}
if (playerY < (80-diameterPlayer/2)) {
vy = 2.5;
}
if (playerX < (0+diameterPlayer/2)) {
vx = 0.1;
}
if(vx>0) {
facingRight = true;
} else if(vx<0) { facingRight = false;
} else facingRight = false;
playerX += vx;
playerY += vy;
}
void draw() {
fill(fillColor);
ellipse(playerX, playerY, diameterPlayer, diameterPlayer);
noFill();
}
}
错误发生在我的主类的第一行(“Player thePlayer = new Player();”),错误显示“找不到类或键入“播放器””。有人请帮助我:(提前谢谢!