Java 关键点输入上的Libgdx纹理太快
我想在按下键时绘制纹理。我使用的是isKeyJustPressed()方法,正因为如此,纹理出现并消失得非常快。我怎样才能让它慢一点,这样我就能看到它的出现?你是这样画纹理的吗Java 关键点输入上的Libgdx纹理太快,java,input,libgdx,textures,Java,Input,Libgdx,Textures,我想在按下键时绘制纹理。我使用的是isKeyJustPressed()方法,正因为如此,纹理出现并消失得非常快。我怎样才能让它慢一点,这样我就能看到它的出现?你是这样画纹理的吗 public void render() { ... batch.begin(); ... if(isKeyJustPressed...) { texture.draw()... } ... batch.end(); ... } 如果是这样
public void render() {
...
batch.begin();
...
if(isKeyJustPressed...) {
texture.draw()...
}
...
batch.end();
...
}
如果是这样,您的纹理将只绘制一帧
如果这是问题所在:
float timeRemaining = 0f; // in seconds
public void render() {
...
batch.begin();
...
if(isKeyJustPressed...) {
timeRemaining = 5; // will show the texture for 5 seconds
}
if (timeRemaining>0) {
timeRemaining -= Gdx.graphics.getDeltaTime();
texture.draw()...
}
...
batch.end();
...
}
另外,我强烈建议您在开始制作游戏之前先阅读本教程。谢谢。事实上,我还没准备好就开始做游戏了。我要花时间学习@Ryncops当我开始制作游戏时,我就像你一样直接开始编码。如果你这样做了也没关系。如果你决定学习的话。只是不要在学习中失去你的雄心壮志。