gpt4 book ai didi

java - 使用 libgdx 设置新屏幕会使我的游戏崩溃?

转载 作者:行者123 更新时间:2023-12-02 04:22:48 25 4
gpt4 key购买 nike

所以我似乎无法弄清楚为什么设置新屏幕会使我的游戏崩溃,我收到的日志消息似乎很简单,但我只是找不到它的根源,所以我希望有人可以帮助我这里..这是日志消息

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 方法中放置一个断点,然后看看发生了什么。如果没有更多信息,我们无法提供帮助!

关于java - 使用 libgdx 设置新屏幕会使我的游戏崩溃?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32555713/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com