libgdx game not disposing

Posted by Yesh on Game Development See other posts from Game Development or by Yesh
Published on 2014-04-07T09:39:13Z Indexed on 2014/06/09 15:44 UTC
Read the original article Hit count: 342

Filed under:

My game does not exit entirely even after calling dispose() method. It loads a black screen when I launch it for the second time and works well if I kill the game manually and restart it.

I get an error that says buffer not allocated with newUnsafeByteBuffer or already disposed when I try to dispose off the SpriteBatch object. This is were I suspect the problem to be. But not able to fix it entirely. Please help!

Here is how I have built it (I have put the sample code here just to show you guys that there are no visible loop backs in dispose function, please correct me if I'm wrong)- In game screen,

public void dispose() { AssetLoader.dispose(); render.dispose(); Gdx.app.exit(); }

Under class AssetLoader-

public void dispose(){ Texture.dispose(); sound.dispose(); }

Under game render class - public void dispose(){ spritebatch.dispose(); //throws an error when I GameScreen.dispose is called font.dispose(); shaperender.dispose(); }

I believe that my spritebatch isn't disposing which is causing the black screen but I cannot find a way to dispose it off successfully. Any help would be greatly appreciated.

© Game Development or respective owner

Related posts about libgdx