Reputation: 15234
Every couple seconds, the window in which my game is playing will briefly disappear and then reappear. I'm on Windows 7 with the latest version of Slick (a game library for Java). Here's the code I'm using:
package Main;
import org.newdawn.slick.*;
public class Main extends BasicGame{
public Main() {
super("Flashing window issue");
}
@Override
public void init(GameContainer gc) throws SlickException {
}
@Override
public void update(GameContainer gc, int delta) throws SlickException {
}
@Override
public void render(GameContainer gc, Graphics g) throws SlickException {
}
public static void main(String[] args) throws SlickException {
AppGameContainer app = new AppGameContainer(new Main());
app.setDisplayMode(800, 600, false);
app.start();
}
}
How can I fix this issue?
Progress so far:
Update: No solution found yet, but playing the game in fullscreen mode eliminates the flicker. Perhaps this will lead to a solution...
Update 2: Monitering the task manager shows that while the game is flickering its status in the task manager is 'Not Responding'.
Update 3: It seems to only happen when the mouse leaves the game area (regardless of whether the game window loses focus).
Update 4 - Current workaround:
app.setMouseGrabbed(true); // force the mouse to stay in the game area
then in update(...):
// exit when escape is pressed:
if (gc.getInput().isKeyDown(Input.KEY_ESCAPE)) {
gc.exit();
}
Upvotes: 1
Views: 267
Reputation: 23301
I'm not familiar with slick2d but does it have a concept of double buffering? that would be something you would want to turn on if you get flickering.
Upvotes: 2