Java can't seem to find my constructor, I have no idea whats wrong. Is there a problem with having the throuws InterruptedException? Any Help would be appreciated, Thanks!
package gameloop;
import javax.swing.*;
public class GameLoop extends JFrame {
private boolean isRunning;
public int drawx = 0;
public int drawy = 0;
public void GameLoop() throws InterruptedException{
setSize(700, 700);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setVisible(true);
while(isRunning){
doGameUpdate();
render();
Thread.sleep(1);
if (isRunning){
GameLoop();
}
}
}
private void doGameUpdate() {
GameUpdate GU = new GameUpdate();
}
private void render() {
Draw dr = new Draw();
}
public static void main(String[] args) {
GameLoop GL = new GameLoop();
}
}
A constructor is named exactly like its class, and has no return type. If you provide a return type, even void
, you create a method called GameLoop
. What you are looking for is
public GameLoop()
rather than
public void GameLoop()
You need public GameLoop()
constructors don't have return types
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With