Alight, so here is the issue.
I dispose of all my stuff. Just in case it doesn’t call dispose(), I call dispose() in the hide() method for com.badlogic.gdx.Screen. I also use a boolean to make sure even if dispose() is called twice, it only disposes of all images, sprites, ect once.
I can’t be posting all of my code on here, it is way too much. What I have notice though is it always happens when I hit “Play” on the screen. So here is my MainMenu class.
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
public class MainMenu implements Screen {
private boolean isDisposed = false;
private TextureAtlas atlas;
private TextButton buttonPlay;
private BitmapFont font;
private Skin skin;
private Stage stage;
private Table table;
public void dispose() {
if(!isDisposed) {
atlas.dispose();
font.dispose();
stage.dispose();
isDisposed = true;
}
}
public void hide() {
dispose();
}
public void pause() {
// TODO Auto-generated method stub
}
public void render(final float delta) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act(delta);
stage.draw();
}
public void resize(final int width, final int height) {
stage.getViewport().update(width, height);
table.invalidateHierarchy();
table.setSize(width, height);
}
public void resume() {
// TODO Auto-generated method stub
}
public void show() {
final FreeTypeFontGenerator generator = new FreeTypeFontGenerator(
Gdx.files.internal("fonts/Track.ttf"));
font = generator.generateFont(80);
generator.dispose();
stage = new Stage(new ScreenViewport());
Gdx.input.setInputProcessor(stage);
atlas = new TextureAtlas(Gdx.files.internal("img/game.pack"));
skin = new Skin(atlas);
table = new Table(skin);
table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
final TextButtonStyle textButtonStyle = new TextButtonStyle();
textButtonStyle.up = skin.getDrawable("button_up");
textButtonStyle.down = skin.getDrawable("button_down");
textButtonStyle.pressedOffsetX = 1;
textButtonStyle.pressedOffsetY = -1;
textButtonStyle.font = font;
textButtonStyle.fontColor = Color.WHITE;
buttonPlay = new TextButton("Play", textButtonStyle);
buttonPlay.addListener(new ClickListener() {
@Override
public void clicked(final InputEvent event, final float x,
final float y) {
((Game) Gdx.app.getApplicationListener()).setScreen(new World(1));
}
});
buttonPlay.pad(20);
table.add(buttonPlay);
stage.addActor(table);
}
}
Also, Here is the error I get in the console.
It also logs two files.
hs_err_pid3320.log - http://pastebin.com/ZG8Ek98R
replay_pid3320.log - http://pastebin.com/bn0GdGnf
I have tried some things, like putting dispose() in the hide() method. However, I am not exactly sure what to do with this type of crash/error as I have never seen anything like it before. Thanks for any help / guidance on the issue.