我收到此错误:Syntax error on token "}", { expected after this token
错误与支架放置
我不知道问题是什么在这里,我已经检查了括号匹配,还是让我觉得,所以我并不完全清楚如何解决这个问题
import java.awt.*;
public class Player extends Entity {
private int directionX, directionY;
private Main instance;
private Rectangle hitbox;
private int life = 3;
public Player(Main instance, int x, int y){
super(x , y);
this.instance = instance;
width = 16; height = 16;
hitbox = new Rectangle(x, y, width, height);
}
public void draw(Graphics g){
move();
g.setColor(Color.WHITE);
g.fillOval(hitbox.x, hitbox.y, hitbox.width, hitbox.height);
g.setColor(Color.WHITE);
g.drawString("Lives: " + life, 20, 20);
}
private void move(){
if(!instance.getStage().isCollided(hitbox)){
directionY = 1;
} else { directionY = 0;
hitbox.x += directionX;
hitbox.y += directionY;
}
} // <<<<<< Getting error here <<<<<<<<<<
if(instance.getEnemyManager().isCollided(hitbox)){
if(life > 0){
life--;
hitbox.x = 800/2 - width/2;
y = 390;
} else {
instance.setGameOver(true);
}
}
public void setdirectionX(int value){
directionX = value;
}
public void setdirectionY(int value){
directionY = value;
}
}
如果有人能回答这个问题我会很高兴知道。