From d0e886259dcb59b683e0a872c6635e48df7e8003 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Mon, 15 Jul 2013 21:45:26 +0100 Subject: [PATCH] Getting ready to overhaul the sound manager. --- Phaser/gameobjects/Sprite.ts | 2 +- Phaser/input/Pointer.ts | 20 +++++++++++++---- Phaser/sound/Sound.ts | 43 +++++++++++++++++++++++++++--------- Phaser/sound/SoundManager.ts | 36 +++++++++++++++++++++--------- README.md | 5 +++++ 5 files changed, 80 insertions(+), 26 deletions(-) diff --git a/Phaser/gameobjects/Sprite.ts b/Phaser/gameobjects/Sprite.ts index 17407cd8..aa1ed7eb 100644 --- a/Phaser/gameobjects/Sprite.ts +++ b/Phaser/gameobjects/Sprite.ts @@ -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; diff --git a/Phaser/input/Pointer.ts b/Phaser/input/Pointer.ts index 288346e4..53add492 100644 --- a/Phaser/input/Pointer.ts +++ b/Phaser/input/Pointer.ts @@ -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 diff --git a/Phaser/sound/Sound.ts b/Phaser/sound/Sound.ts index 83670f07..6f169aec 100644 --- a/Phaser/sound/Sound.ts +++ b/Phaser/sound/Sound.ts @@ -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; + } } diff --git a/Phaser/sound/SoundManager.ts b/Phaser/sound/SoundManager.ts index 9e39e33c..7ced4fbd 100644 --- a/Phaser/sound/SoundManager.ts +++ b/Phaser/sound/SoundManager.ts @@ -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; + } } diff --git a/README.md b/README.md index 78caf848..efd69115 100644 --- a/README.md +++ b/README.md @@ -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