I'm in the process of creating a simple game and I stumbled upon an error I can't resolve. When trying to import/draw an image with Graphics an error pops up:
Multiple markers at this line
- getCenterX cannot be resolved or is not a field
- getCenterY cannot be resolved or is not a field
- getCenterY cannot be resolved or is not a field
I'm most certain that I imported everything correctly:
// In the class "StartingClass"
private Robot robot;
private URL base;
// In the class "Robot"
private int centerX = 100;
private int centerY = 328;
@Override
public void paint(Graphics g) {
g.drawImage(character, robot.getCenterX()- 61, robot.getCenterY - 62, this);
}
@Override
public void start() {
robot = new Robot();
}
public int getCenterX() {
return centerX;
}
public int getCenterY() {
return centerY;
}
robot.getCenterY
I think the problem is this, as getCenterY is not a variable. Its a typo for the method getCenterY(). To fix, just add the parenthetical at the end. Otherwise, please post more snippets as not much can be determined from your code provided.