Error:
java.lang.IllegalArgumentException: capacity < 0: (-1611268096 < 0)
at java.base/java.nio.Buffer.createCapacityException(Buffer.java:279)
at java.base/java.nio.Buffer.<init>(Buffer.java:242)
at java.base/java.nio.ByteBuffer.<init>(ByteBuffer.java:288)
at java.base/java.nio.ByteBuffer.<init>(ByteBuffer.java:296)
at java.base/java.nio.MappedByteBuffer.<init>(MappedByteBuffer.java:112)
at java.base/java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:170)
at com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.newPixmap(Native Method)
at com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.<init>(Gdx2DPixmap.java:137)
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
at com.tds.game.GifDecoder.getAnimation(GifDecoder.java:697)
at com.tds.game.GifDecoder.loadGIFAnimation(GifDecoder.java:731)
at com.tds.game.AfterBossScreen.show(AfterBossScreen.java:26)
at com.badlogic.gdx.Game.setScreen(Game.java:63)
at com.tds.game.updateAndDrawBulletsAndBadBoys.updateAndDrawBadBoys(updateAndDrawBulletsAndBadBoys.java:179)
at com.tds.game.MainGameScreen.render(MainGameScreen.java:157)
at com.badlogic.gdx.Game.render(Game.java:48)
at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window.update(Lwjgl3Window.java:387)
at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.loop(Lwjgl3Application.java:193)
at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:167)
at com.tds.game.DesktopLauncher.main(DesktopLauncher.java:14)
I tried to use other libraries for decryption, but it didn’t work. I also created a gifdecoder as a class.
Changed:
Gif size is 2560x1440px, idk why do you need this information.
Gif isn’t damaged, and that’s what you asked:
Code around AfterBossScreen.java:26:
@Override
public void show() {
System.out.println("AfterBossScreen show() called");
font = new BitmapFont();
batch = new SpriteBatch();
// Загрузка GIF
try {
animation = GifDecoder.loadGIFAnimation(Animation.PlayMode.LOOP,Gdx.files.internal("begin.gif").read()); // stroke 26
System.out.println("AfterBossScreen: Animation loaded");
} catch (Exception e) {
System.out.println("Error loading GIF: " + e.getMessage());
e.printStackTrace();
}
batch.begin();
font.draw(batch, "Loading...", 100, 100);
batch.end();
}
GifDecoder.java:697:
public Animation<TextureRegion> getAnimation(PlayMode playMode) {
int nrFrames = getFrameCount();
Pixmap frame = getFrame(0);
int width = frame.getWidth();
int height = frame.getHeight();
int vzones = (int)Math.sqrt((double)nrFrames);
int hzones = vzones;
while(vzones * hzones < nrFrames) vzones++;
int v, h;
Pixmap target = new Pixmap(width * hzones, height * vzones, Pixmap.Format.RGBA8888); // stroke 697
for(h = 0; h < hzones; h++) {
for(v = 0; v < vzones; v++) {
int frameID = v + h * vzones;
if(frameID < nrFrames) {
frame = getFrame(frameID);
target.drawPixmap(frame, h * width, v * height);
}
}
}
Texture texture = new Texture(target);
Array<TextureRegion> texReg = new Array<TextureRegion>();
for(h = 0; h < hzones; h++) {
for(v = 0; v < vzones; v++) {
int frameID = v + h * vzones;
if(frameID < nrFrames) {
TextureRegion tr = new TextureRegion(texture, h * width, v * height, width, height);
texReg.add(tr);
}
}
}
float frameDuration = (float)getDelay(0);
frameDuration /= 1000; // convert milliseconds into seconds
Animation<TextureRegion> result = new Animation<TextureRegion>(frameDuration, texReg, playMode);
return result;
}
updateAndDrawBulletsAndBadBoys.java:179:
if(boss != null){
if(boss.x <= 16){
System.out.println("}-- Boss is in the end");
game.setScreen(new AfterBossScreen()); // stroke 179
return;
}
}
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.