My gif file isn’t playing, but there is no errors in console.
Render method:
@Override
public void render(float delta) {
elapsed += Gdx.graphics.getDeltaTime();
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
if (animation != null) {
TextureRegion frame = animation.getKeyFrame(elapsed);
batch.draw(frame, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
System.out.println("Frame " + elapsed + " played");
} else {
System.out.println("Animation is null");
}
batch.end();
}
Show method:
@Override
public void show() {
System.out.println("AfterBossScreen show() called");
font = new BitmapFont();
batch = new SpriteBatch();
// gif load
try {
animation = GifDecoder.loadGIFAnimation(Animation.PlayMode.LOOP, Gdx.files.internal("begin.gif").read());
System.out.println("AfterBossScreen: Animation loaded");
} catch (Exception e) {
System.out.println("Error loading GIF: " + e.getMessage());
e.printStackTrace();
}
}
I checked the GifDecoder and Animation classes, end i didn’t find any bug.
New contributor
Prostoblodi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.