Hi, back when I was using Java2D I used this code to listen to the mousewheel.
canvas.addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (-e.getWheelRotation() == 1) {
//Do stuff
} else if (-e.getWheelRotation() == -1) {
//Do stuff
}
}
});
How do I listen to the mouse wheel with Slick2D? I have this but I can’t find an option for mouse wheel.
public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
Input input = gc.getInput();
//input. <---- I did input.addMouseListener(new MouseWheelListener) { } but had errors with that
}
My second issue I’m having with input is when the user hits keys on the keyboard the program registers it each time it updates the game loop (I currently have it set to 60fps). To better explain my issue: I have a main menu and when I hit the up arrow to go to the next option it jumps a couple of options because I didn’t click on the up arrow super quickly. I could sleep the Thread but that would pause the whole game. Does someone know how I can fix this? Here is some code to show what I’m doing. Fixed! x), I changed it to input.isKeyPressed
When moving sprites how do I use delta time? I’ve seen tutorials that use delta time and I’m not quite sure why I’d need to. For example I’ve seen x += delta * 0.1 * 1 , why can’t I just do x += movementSpeed;
Last question, why isn’t v-sync standard? Is there some reason on why I shouldn’t use v-sync?
Thank you so much for your time.