0
\$\begingroup\$

In my almost finished game I want to set a new screen on game over. I got my game over method:

    private void gameOver(Label score) {
    for (Body body : worldBodies) {
        world.destroyBody(body);
        dispose();
        ((Game) Gdx.app.getApplicationListener()).setScreen(new GameOver());
    }
}

Whenever the method gets called the screen freezes for a second and the game crashes with this statement:

09-02 22:04:34.036      391-425/com.joelbrun.jetskirider.android A/libc﹕ Fatal signal 11 (SIGSEGV), code 1, fault addr 0x8 in tid 425 (GLThread 29501)
\$\endgroup\$
2
  • \$\begingroup\$ More information is needed to pin-point what's going wrong here, for example; Do you have any joints between bodies that are being destroyed? What does the dispose method do? Do you hit any method that tries to use the destroyed bodies after this call? \$\endgroup\$ – bornander Sep 3 '15 at 8:24
  • \$\begingroup\$ Please show the dispose(); method. \$\endgroup\$ – TomGrill Games Sep 3 '15 at 17:35
3
\$\begingroup\$

Move this after the for loop:

dispose();
((Game) Gdx.app.getApplicationListener()).setScreen(new GameOver());

You create/set a new GameOver Screen each iteration, that causes probably the freeze and problems.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.