Sign in to follow this  
damager

Sound muteOnPause problem

Recommended Posts

Hi, i have music in my game, but i don't want to stop it when game paused. I found "this.game.muteOnPause = false" but it doesn't work. What am i doing wrong? Thanks.

Phaser v2.10.0

Share this post


Link to post
Share on other sites

Wow, I just posted a similar thread before seeing this one existed. I almost feel bad.

By any chance, does it mute when the game window is unfocused or only when it's triggered ingame? 

Share this post


Link to post
Share on other sites

Okay, i don't know who is fixing bugs on phaser. But that was definately bug. I add code of checking boolean "muteOnPause", cause that checking was only in Stage Visability handler, not in game pause setter. I think that there's can be another variable like "muteOnDomPause" and "muteOnPause".

set: function (value) {

    if (value === true)
    {
        if (this._paused === false)
        {
            this._paused = true;
            if (this.sound.muteOnPause)
            {
                this.sound.setMute();
            }
            this.time.gamePaused();
            this.onPause.dispatch(this);
        }
        this._codePaused = true;
    }
    else
    {
        if (this._paused)
        {
            this._paused = false;
            if (this.sound.muteOnPause)
            {
                this.sound.unsetMute();
            }
            this.input.reset();
            this.time.gameResumed();
            this.onResume.dispatch(this);
        }
        this._codePaused = false;
    }

}

P.S In my game i did the next thing: i create 2 variables: muteOnDOMPause and muteOnPause. and every usage of previous of muteOnPause i change as muteOnDOMPause, and in setter of game pause  and only there i use muteOnPause; In game i can actually choose what kind of mute i need

Share this post


Link to post
Share on other sites

It's always worked this way. I guess it should be called muteOnBlur.

If you're setting game.pause yourself you can just set game.sound.mute as well. Or use the onPause/onResume signals.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.