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.