Phaser Game - Pause Feature

I want to implement pause feature in game, this is what i have tried -
Inside Update method :

        // Pause Game
        if (Phaser.Input.Keyboard.JustDown(gameState.cursors.pause)) {
            console.log(`isPaused : ${this.scene.isPaused()}`);
            console.log(`isActive : ${this.scene.isActive()}`);
            if (this.scene.isActive()) {
                this.scene.pause();
            } else if (this.scene.isPaused()) {
                this.scene.resume();
            }
            console.log(`isPaused : ${this.scene.isPaused()}`);
            console.log(`isActive : ${this.scene.isActive()}`);
        }

it is able to pause my screen but resume is not working. else if part is not working… please help

Would you need it to be an else if, specifically?

I presume that your game can only be in one of two states - paused, or not paused.

Logically then, we can leave the original if (this.scene.isActive()), and replace the else if (this.scene.isPaused()) with a regular else condition.

I’m also assuming that, given you’re logging their values to the console, that when the game is paused this.scene.isActive() returns false?

I solved it. thanks for help :slight_smile:

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.