So i cant seem to figured out for the life of me why setting a new screen crashes my game, the log message i get seems pretty straight forward but i just cant find the root of it so i was hoping someone could help me out here.. Here is the log message
java(1240,0x1e59cb000) malloc: *** error for object 0x7f8cf4ad2208: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Here is the code that calls the setScreen method, I don't see where i'm modifying a freed object Hopefully someone can enlighten me on this subject
public class GameScreen implements Screen {
//..
public void updateWorld(float deltaTime){
switch (gameState) {
case START:
//..
break;
case RUNNING:
//..
break;
case GAMEOVER:
System.out.println("called");
//..
fishy.setGRAVITY(-20);
fishy.update(deltaTime);
if (gos == null) gos = new GameOverState(game);
gos.compareScore(curr_ig_score);
backgroundMusic.pause();
if (!gameOver.isPlaying()) gameOver.play();
fishy.setMOVEMENT_X(0);
updateGOSButtons();
break;
case PAUSED:
//...
break;
}
//..
}
public void updateGOSButtons() {
if (gos.isGoButtonClicked()) {
gameOver.stop();
backgroundMusic.play();
dispose();
game.setScreen(new GameScreen(game));
}
if (gos.isHomeButtonClicked()) {
gameOver.stop();
backgroundMusic.play();
dispose();
game.setScreen(new MainMenuScreen(game));
}
Gdx.input.setInputProcessor(gos.getStage());
}
}
From another thread:
What's happening is one of the following:
1) you are freeing an object twice,
2) you are freeing a pointer that was never allocated
3)you are writing through an invalid pointer which previously pointed to an object which was already freed
The best way is to put a breakpoint in the: malloc_error_break
methods and see what's happening. Without more info it's impossible for us to help!