光滑的二维光标消失错误

Slick 2d cursor disappearing bug

开始游戏后不久,光标消失,每当我尝试将其带回游戏时开始出现错误 window,然后在 window 中再次消失。这是使用自定义光标的 class 的代码:


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;
    }

}

所以我刚才解决了这个问题,但最好的办法是用空白图像替换光标,然后为实际光标制作一个新精灵并将其位置设置为鼠标的位置。