【发布时间】:2014-04-15 15:35:38
【问题描述】:
您好,我在 Libgdx 中有一个 spritebatch 动画。它只播放一次,完成后我想停止绘制它,这样它就不会出现在屏幕上。我有一个布尔值来检查它是否还活着,即动画,当动画使用 isAnimationFinished 完成时它设置为 false 但是它停留在屏幕上,我不确定为什么即使日志打印显示它在完成时变为 false .有谁知道这是为什么?谢谢你的帮助。以下代码来自我的渲染方法。
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); // This cryptic line clears the screen.
boolean alive = true;
stateTime += Gdx.graphics.getDeltaTime(); // #15
currentFrame = walkAnimation.getKeyFrame(stateTime, false); // #16
spriteBatch.begin();
spriteBatch.draw(menu, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
if (alive)
spriteBatch.draw(currentFrame,50,50);
if(walkAnimation.isAnimationFinished(stateTime))
alive = false;
System.out.println(alive);
spriteBatch.end();
stage.draw();
【问题讨论】: