Jump to content

Java Side Slider Issue

chazat123

Got a slight issue in this, if anyone could help that'd be ace! (2nd issue)
I'm making a basic 2D Side Scroller Game
Here's the code:
 

private void update() {}private void draw() {}private void drawToScreen() {}Graphics g2 = getGraphics();g2.drawImage(image, 0, 0, null);g2.dispose(image, 0, 0, null);  public void keyTyped(KeyEvent key) {}public void keyPressed(KeyEvent key) {}public void keyReleased(KeyEvent key) {} }

It's displaying Multiple markers at this line
- Syntax error on tokens, VariableDeclarator expected 
instead
- Syntax error on token "(", delete this token

Link to comment
Share on other sites

Link to post
Share on other sites

Any particulars on the issue, I don't have a java compiler right now.  Are you getting errors, or is it not showing up correctly?

 

Also by the looks of it, you have the braces unbalanced.

e.g.

public class GamePanel extends JPanel 
implements Runnable, KeyListener{
 
} //You are closing out of the public class with this close brace
 
 
Finally...if it isn't too much to ask, could you edit your original post to put the code in a code tag.  (The <> symbol and paste your code in there from your original code....it will make things a lot easier to read through)

0b10111010 10101101 11110000 00001101

Link to comment
Share on other sites

Link to post
Share on other sites

 

Any particulars on the issue, I don't have a java compiler right now.  Are you getting errors, or is it not showing up correctly?

 

Also by the looks of it, you have the braces unbalanced.

e.g.

public class GamePanel extends JPanel 
implements Runnable, KeyListener{
 
} //You are closing out of the public class with this close brace
 
 
Finally...if it isn't too much to ask, could you edit your original post to put the code in a code tag.  (The <> symbol and paste your code in there from your original code....it will make things a lot easier to read through)

 

I've done that! And the errors I'm receiving are:

Multiple markers at this line
- Syntax error on token(s), misplaced 
construct(s)
- Syntax error on tokens, delete these 
tokens
- Syntax error on tokens, delete these 
tokens
 
EDIT! Super, top man, all fixed! Need to have more friends like you! I'm just learning Javascript! :)
Link to comment
Share on other sites

Link to post
Share on other sites


private void update() {}

private void draw() {}

private void drawToScreen() {} //Closing the drawToScreen but it appears as though you intended to have this method continue..ie } closing it

Graphics g2 = getGraphics(); //This is now being defined in the class, not in a method

g2.drawImage(image, 0, 0, null); //Same as the prev

g2.dispose(image, 0, 0, null); //Same

public void keyTyped(KeyEvent key) {}

public void keyPressed(KeyEvent key) {}

public void keyReleased(KeyEvent key) {}

}

0b10111010 10101101 11110000 00001101

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×