使用 libgdx 设置新屏幕会使我的游戏崩溃?
setting a new screen with libgdx crashes my game?
所以我似乎一辈子都弄不明白为什么设置新屏幕会使我的游戏崩溃,我收到的日志消息看起来很简单,但我就是找不到它的根源所以我希望有人能帮帮我。这是日志消息
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
这是调用 setScreen 方法的代码,我没有看到我在哪里修改释放的对象希望有人能启发我这个问题
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());
}
}
来自另一个线程:
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
最好的方法是在以下方法中放置一个断点:malloc_error_break
方法并查看发生了什么。没有更多信息,我们无法提供帮助!
我最近 运行 遇到了一个类似的问题,这是我在渲染周期中间更改屏幕时引起的。发生的事情是当前屏幕将被隐藏和处理,然后它会尝试使用舞台和其他已经处理过的对象来渲染它。我不得不将 set screen 方法移动到渲染调用的末尾,问题已解决。
所以我似乎一辈子都弄不明白为什么设置新屏幕会使我的游戏崩溃,我收到的日志消息看起来很简单,但我就是找不到它的根源所以我希望有人能帮帮我。这是日志消息
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
这是调用 setScreen 方法的代码,我没有看到我在哪里修改释放的对象希望有人能启发我这个问题
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());
}
}
来自另一个线程:
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
最好的方法是在以下方法中放置一个断点:malloc_error_break
方法并查看发生了什么。没有更多信息,我们无法提供帮助!
我最近 运行 遇到了一个类似的问题,这是我在渲染周期中间更改屏幕时引起的。发生的事情是当前屏幕将被隐藏和处理,然后它会尝试使用舞台和其他已经处理过的对象来渲染它。我不得不将 set screen 方法移动到渲染调用的末尾,问题已解决。