A little while after starting the game, the cursor disappears and starts bugging out whenever I try to bring it back into the game window before disappearing again once back inside the window. This is the code for the class that uses the custom cursor:
import org.lwjgl.input.Mouse;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
public class Clicker extends BasicGameState {
Flower flower = new Flower();
public Clicker(int state) {
}
public void init(GameContainer container, StateBasedGame game) throws SlickException {
container.setMouseCursor("res/cursor/cursor.png", 0, 0);
flower.flower = new Image("res/flower.png");
}
public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
g.drawImage(flower.flower, flower.X, flower.Y);
}
public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException {
if (Mouse.isButtonDown(0)) {
container.setMouseCursor("res/cursor/cursor_pressed.png", 0, 0);
if (flower.hitbox.contains(Mouse.getX(), 750 - Mouse.getY())) {
flower.newX();
flower.newY();
}
} else {
container.setMouseCursor("res/cursor/cursor.png", 0, 0);
}
}
public int getID() {
return 2;
}
}
So I solved this a while ago, but the best thing to do was to replace the cursor with a blank image, and then make a new sprite for the actual cursor and set its position to that of the mouse.