Everything Good But On Second Game Demo Play Nothing Happens(No Crash)?

Hi,

Almost there…
Working with the official demo.
Everything is working except when we play a second game?

The 12 stars show at top of screen, but do not fall(physics)?
Also the player is not shown either?

You can play the current build on Itch below:

The full source code is below as well:
https://bitbucket.org/jesseleepalser/phaser-engine/src/master/

I’ll continue to work on this, but if you see something let me know here.
Thanks!

Jesse Lee

After

this.physics.pause()

you need

this.physics.resume()

For game object destruction, do

player.destroy();

platforms.destroy(true);
stars.destroy(true);
bombs.destroy(true);

Only group destroy() has the destroyChildren argument.

Hi,

Game now crashes in phaser.min.js on 2nd game, so I can’t pinpoint the crash in my source code.

I’ve updated the source code repository below:
https://bitbucket.org/jesseleepalser/phaser-engine/src/master/

If you would like to run the game on Itch then visit below URL:

Very lost here, hope you can figure this out.

Jesse Lee

I think the crash is at below line of code, but don’t understand why?:
https://bitbucket.org/jesseleepalser/phaser-engine/src/7074446d7330ed66264e2369267ef793e0d9393e/coreLogic.js#lines-65

Sorry it crashes on below code, please advise:

//--------------------------------------------------------------------------------------------------------------
function DeleteAllVisualsForGameOver ()
{
//    platforms.destroy(true); // CRASHES?

    player.destroy();

//    stars.destroy(true); // CRASHES?

//    bombs.destroy(true); // CRASHES?
}

//--------------------------------------------------------------------------------------------------------------

If I comment out below line the crash goes away, but then the physics are not enabled?

https://bitbucket.org/jesseleepalser/phaser-engine/src/7074446d7330ed66264e2369267ef793e0d9393e/coreLogic.js#lines-65

I got it running on 2nd run, but unable to delete demo platforms, stars, or bombs?:
https://bitbucket.org/jesseleepalser/phaser-engine/src/f6caf2956f32d0b04dc3fc38601f5b6e5d4fb0c4/coreLogic.js#lines-53

//--------------------------------------------------------------------------------------------------------------
function DeleteAllVisualsForGameOver ()
{
//    platforms.destroy(true); // CRASHES on second run of game?

    player.destroy();

//    stars.destroy(true); // CRASHES on second run of game?

//    bombs.destroy(true); // CRASHES on second run of game?
}

//--------------------------------------------------------------------------------------------------------------

This error happens because the colliders you added with add.collider() are still running but their game objects have been destroyed.

You can remove the colliders and then replace them.

playerBombsCollider = this.add.collider(/*…*/);
// …
this.physics.world.removeCollider(playerBombsCollider);

That worked - demo game 100%
Moving forward!