Getting ready to overhaul the sound manager.

This commit is contained in:
Richard Davey 2013-07-15 21:45:26 +01:00
parent b3fff37faf
commit d0e886259d
5 changed files with 80 additions and 26 deletions

View file

@ -82,7 +82,7 @@ module Phaser {
this.transform.setCache();
this.outOfBounds = false;
this.outOfBoundsAction = Phaser.Types.OUT_OF_BOUNDS_KILL;
this.outOfBoundsAction = Phaser.Types.OUT_OF_BOUNDS_PERSIST;
// Handy proxies
this.scale = this.transform.scale;

View file

@ -33,6 +33,10 @@ module Phaser {
}
private _highestRenderOrderID: number;
private _highestRenderObject: number;
private _highestInputPriorityID: number;
/**
* Local private reference to game.
* @property game
@ -239,6 +243,13 @@ module Phaser {
**/
public totalTouches: number = 0;
/**
* The number of miliseconds since the last click
* @property msSinceLastClick
* @type {Number}
**/
public msSinceLastClick: number = Number.MAX_VALUE;
/**
* How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1.
* @property duration
@ -306,7 +317,12 @@ module Phaser {
this.withinGame = true;
this.isDown = true;
this.isUp = false;
// Work out how long it has been since the last click
this.msSinceLastClick = this.game.time.now - this.timeDown;
this.timeDown = this.game.time.now;
this._holdSent = false;
// This sets the x/y and other local values
@ -371,10 +387,6 @@ module Phaser {
}
private _highestRenderOrderID: number;
private _highestRenderObject: number;
private _highestInputPriorityID: number;
/**
* Called when the Pointer is moved on the touchscreen
* @method move

View file

@ -50,27 +50,35 @@ module Phaser {
* Local private reference to AudioContext.
*/
private _context;
/**
* Reference to gain node of SoundManager.
*/
private _gainNode;
/**
* GainNode of this sound.
*/
private _localGainNode;
/**
* Decoded data buffer.
*/
private _buffer;
/**
* Volume of this sound.
*/
private _volume: number;
/**
* The real sound object (buffer source).
*/
private _sound;
private _muteVolume: number;
private _muted: bool = false;
loop: bool = false;
duration: number;
isPlaying: bool = false;
@ -125,27 +133,40 @@ module Phaser {
}
/**
* Mute the sound.
* Mute sounds.
*/
public mute() {
this._localGainNode.gain.value = 0;
public get mute():bool {
return this._muted;
}
/**
* Enable the sound.
*/
public unmute() {
public set mute(value: bool) {
this._localGainNode.gain.value = this._volume;
if (value && this._muted == false)
{
this._muteVolume = this._localGainNode.gain.value;
this._localGainNode.gain.value = 0;
this._muted = true;
}
else
{
this._localGainNode.gain.value = this._muteVolume;
this._muted = false;
}
}
public set volume(value: number) {
this._volume = value;
this._localGainNode.gain.value = this._volume;
if (this._muted)
{
this._muteVolume = this._volume;
}
else
{
this._localGainNode.gain.value = this._volume;
}
}

View file

@ -66,28 +66,44 @@ module Phaser {
*/
private _volume: number;
private _muteVolume: number;
private _muted: bool = false;
/**
* Mute sounds.
*/
public mute() {
this._gainNode.gain.value = 0;
public get mute():bool {
return this._muted;
}
/**
* Enable sounds.
*/
public unmute() {
public set mute(value: bool) {
this._gainNode.gain.value = this._volume;
if (value && this._muted == false)
{
this._muteVolume = this._gainNode.gain.value;
this._gainNode.gain.value = 0;
this._muted = true;
}
else
{
this._gainNode.gain.value = this._muteVolume;
this._muted = false;
}
}
public set volume(value: number) {
this._volume = value;
this._gainNode.gain.value = this._volume;
if (this._muted)
{
this._muteVolume = this._volume;
}
else
{
this._gainNode.gain.value = this._volume;
}
}

View file

@ -57,6 +57,11 @@ TODO:
* Camera control method (touch/keyboard)
* Tilemap.destroy needs doing
* Look at the input targetObject - it doesn't seem to get cleared down all the time, maybe just a priority/alpha issue (check vis/alpha?)
* Sprite.transform.bottomRight/Left doesn't seem to take origin into account
* When you toggle visible of a button that is over, it doesn't disable that 'over' state (should it? probably yes)
* Stage.opaqueBackground = 'rgb()' or null, alpha, blendMode, filters, mask, rotation+XYZ,scaleXYZ,visible
V1.0.0