Sound.restart used to cause the Sound to double-up if it was already playing when called. Now correctly stops the sound before restarting it (thanks @wombatbuddy #1136)

This commit is contained in:
photonstorm 2014-08-29 01:06:29 +01:00
parent dd9e7e6297
commit 52ea95d9ce
2 changed files with 8 additions and 8 deletions

View file

@ -138,6 +138,7 @@ Version 2.1.0 - "Cairhien" - -in development-
* If you used a single Game configuration object and didn't specify the enableDebug property it would crash on Debug.preUpdate (thanks @luizbills #1053)
* The P2.World.postBroadphaseHandler now checks if the returned pairs array is empty or not before processing it (thanks @wayfu #934)
* Tilemap.hasTile now checks the Tile.index value and will return false if the index is -1 (i.e. a non-active tile) (thanks @elgansayer #859)
* Sound.restart used to cause the Sound to double-up if it was already playing when called. Now correctly stops the sound before restarting it (thanks @wombatbuddy #1136)
### p2.js 0.6.0 Changes and New Features

View file

@ -308,7 +308,7 @@ Phaser.Sound.prototype = {
*/
soundHasUnlocked: function (key) {
if (key == this.key)
if (key === this.key)
{
this._sound = this.game.cache.getSoundData(this.key);
this.totalDuration = this._sound.duration;
@ -362,11 +362,10 @@ Phaser.Sound.prototype = {
*/
update: function () {
if (this.isDecoded && !this._onDecodedEventDispatched) {
if (this.isDecoded && !this._onDecodedEventDispatched)
{
this.onDecoded.dispatch(this);
this._onDecodedEventDispatched=true;
this._onDecodedEventDispatched = true;
}
if (this.pendingPlayback && this.game.cache.isSoundReady(this.key))
@ -435,13 +434,13 @@ Phaser.Sound.prototype = {
if (typeof marker === 'undefined') { marker = ''; }
if (typeof forceRestart === 'undefined') { forceRestart = true; }
if (this.isPlaying === true && forceRestart === false && this.override === false)
if (this.isPlaying && !forceRestart && !this.override)
{
// Use Restart instead
return this;
}
if (this.isPlaying && this.override)
if (this.isPlaying && (this.override || forceRestart))
{
if (this.usingWebAudio)
{
@ -520,7 +519,7 @@ Phaser.Sound.prototype = {
if (this.game.cache.isSoundDecoded(this.key))
{
// Do we need to do this every time we play? How about just if the buffer is empty?
if (this._buffer == null)
if (this._buffer === null)
{
this._buffer = this.game.cache.getSoundData(this.key);
}