mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
SoundManager.muteOnPause is a new boolean that allows you to control if the Sound system gets muted automatically when a Phaser game pauses, such as when it loses focus. You may need to set this to false
if you wish to control the audio system from outside of your Phaser game, i.e. from DOM buttons or similar (#2382)
This commit is contained in:
parent
61bc4a8dca
commit
896b32a28c
5 changed files with 31 additions and 4 deletions
|
@ -328,6 +328,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
|
|||
* Group.getByName searches the Group for the first instance of a child with the `name` property matching the given argument. Should more than one child have the same name only the first instance is returned.
|
||||
* BitmapData has a new property `frameData` which is a Phaser.FrameData container instance. It contains a single Frame by default, matching the dimensions of the entire BitmapData, but can be populated with additional frames should you wish to create animations from dynamic BitmapData textures.
|
||||
* FrameData.destroy will nullify the local arrays used to contain Frame instances.
|
||||
* SoundManager.muteOnPause is a new boolean that allows you to control if the Sound system gets muted automatically when a Phaser game pauses, such as when it loses focus. You may need to set this to `false` if you wish to control the audio system from outside of your Phaser game, i.e. from DOM buttons or similar (#2382)
|
||||
|
||||
### Updates
|
||||
|
||||
|
|
|
@ -1045,8 +1045,14 @@ Phaser.Game.prototype = {
|
|||
if (!this._paused)
|
||||
{
|
||||
this._paused = true;
|
||||
|
||||
this.time.gamePaused();
|
||||
this.sound.setMute();
|
||||
|
||||
if (this.sound.muteOnPause)
|
||||
{
|
||||
this.sound.setMute();
|
||||
}
|
||||
|
||||
this.onPause.dispatch(event);
|
||||
|
||||
// Avoids Cordova iOS crash event: https://github.com/photonstorm/phaser/issues/1800
|
||||
|
@ -1071,9 +1077,16 @@ Phaser.Game.prototype = {
|
|||
if (this._paused && !this._codePaused)
|
||||
{
|
||||
this._paused = false;
|
||||
|
||||
this.time.gameResumed();
|
||||
|
||||
this.input.reset();
|
||||
this.sound.unsetMute();
|
||||
|
||||
if (this.sound.muteOnPause)
|
||||
{
|
||||
this.sound.unsetMute();
|
||||
}
|
||||
|
||||
this.onResume.dispatch(event);
|
||||
|
||||
// Avoids Cordova iOS crash event: https://github.com/photonstorm/phaser/issues/1800
|
||||
|
|
|
@ -94,6 +94,15 @@ Phaser.SoundManager = function (game) {
|
|||
*/
|
||||
this.channels = 32;
|
||||
|
||||
/**
|
||||
* Set to true to have all sound muted when the Phaser game pauses (such as on loss of focus),
|
||||
* or set to false to keep audio playing, regardless of the game pause state. You may need to
|
||||
* do this should you wish to control audio muting via external DOM buttons or similar.
|
||||
* @property {boolean} muteOnPause
|
||||
* @default
|
||||
*/
|
||||
this.muteOnPause = true;
|
||||
|
||||
/**
|
||||
* @property {boolean} _codeMuted - Internal mute tracking var.
|
||||
* @private
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
* It allows you to exclude the default Sound Manager from your build, without making Game crash.
|
||||
*/
|
||||
|
||||
Phaser.SoundManager = function () {};
|
||||
Phaser.SoundManager = function () {
|
||||
this.muteOnPause = false;
|
||||
};
|
||||
|
||||
Phaser.SoundManager.prototype.boot = function () {};
|
||||
Phaser.SoundManager.prototype.update = function () {};
|
||||
|
|
4
typescript/phaser.d.ts
vendored
4
typescript/phaser.d.ts
vendored
|
@ -1,7 +1,7 @@
|
|||
/// <reference path="pixi.d.ts" />
|
||||
/// <reference path="p2.d.ts" />
|
||||
|
||||
// Type definitions for Phaser 2.4.7 - 1st March 2016
|
||||
// Type definitions for Phaser 2.4.7 - 6th April 2016
|
||||
// Project: https://github.com/photonstorm/phaser
|
||||
|
||||
declare module "phaser" {
|
||||
|
@ -1689,6 +1689,7 @@ declare module Phaser {
|
|||
filter(predicate: Function, checkExists?: boolean): ArraySet;
|
||||
getAt(index: number): PIXI.DisplayObject | number;
|
||||
getBottom(): any;
|
||||
getByName(name: string): any;
|
||||
getFirstAlive(createIfNull?: boolean, x?: number, y?: number, key?: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture, frame?: string | number): any;
|
||||
getFirstDead(createIfNull?: boolean, x?: number, y?: number, key?: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture, frame?: string | number): any;
|
||||
getFirstExists(exists: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture, frame?: string | number): any;
|
||||
|
@ -4350,6 +4351,7 @@ declare module Phaser {
|
|||
context: any;
|
||||
game: Phaser.Game;
|
||||
mute: boolean;
|
||||
muteOnPause: boolean;
|
||||
noAudio: boolean;
|
||||
onSoundDecode: Phaser.Signal;
|
||||
onVolumeChange: Phaser.Signal;
|
||||
|
|
Loading…
Reference in a new issue