I'm developing a small game engine in Java and I use Swing to collect input and display graphics. I'm having a strange bug with MouseMoved
events and I'm wondering whether the EDT handles the inputs in a given order or not, to understand if something else is wrong with my code or not. I couldn't find any information online. This is my mouseMoved()
method:
gameFrame.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
GameScene lastScene = null;
synchronized (scenes) {
if (scenes.size() > 0) {
lastScene = scenes.get(scenes.size() - 1);
}
}
if (lastScene != null && lastScene.isRunning()) {
lastScene.mouseMoved((int) (e.getX() / scale), (int) (e.getY() / scale), cameraX, cameraY, scale);
}
}
});
According to System.nanotime()
it runs in way less than a millisecond.