From 74bee324a53b90d014134a9f4a8ce4b68f5afc60 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Wed, 11 Feb 2015 13:52:16 +0000 Subject: [PATCH] Sound.fadeIn now supports fading from a marker, as well as the entire audio clip, so now works with audio sprites (thanks @vorrin #1413) --- README.md | 1 + src/sound/Sound.js | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fa457716b..07d62ed71 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,7 @@ Thanks to @pnstickne for vast majority of this update. * Loader.onLoadComplete is dispatched *before* the Loader is reset. If you have a `create` method in your State please note that the Loader will have been reset before this method is called. This allows you to immediately re-use the Loader without having to first reset it manually. * World.setBounds will now adjust the World.x/y values to match those given (#1555) * ArcadePhysics.distanceToPointer now calculates the distance in world space values. +* Sound.fadeIn now supports fading from a marker, as well as the entire audio clip, so now works with audio sprites (thanks @vorrin #1413) ### Bug Fixes diff --git a/src/sound/Sound.js b/src/sound/Sound.js index 56f27c4ca..d59ec7fac 100644 --- a/src/sound/Sound.js +++ b/src/sound/Sound.js @@ -840,28 +840,31 @@ Phaser.Sound.prototype = { /** * Starts this sound playing (or restarts it if already doing so) and sets the volume to zero. * Then increases the volume from 0 to 1 over the duration specified. + * * At the end of the fade Sound.onFadeComplete is dispatched with this Sound object as the first parameter, * and the final volume (1) as the second parameter. * * @method Phaser.Sound#fadeIn * @param {number} [duration=1000] - The time in milliseconds over which the Sound should fade in. * @param {boolean} [loop=false] - Should the Sound be set to loop? Note that this doesn't cause the fade to repeat. + * @param {string} [marker=(current marker)] - The marker to start at; defaults to the current (last played) marker. To start playing from the beginning specify specify a marker of `''`. */ - fadeIn: function (duration, loop) { + fadeIn: function (duration, loop, marker) { if (typeof loop === 'undefined') { loop = false; } + if (typeof marker === 'undefined') { marker = this.currentMarker; } if (this.paused) { return; } - this.play('', 0, 0, loop); + this.play(marker, 0, 0, loop); this.fadeTo(duration, 1); }, - + /** * Decreases the volume of this Sound from its current value to 0 over the duration specified. * At the end of the fade Sound.onFadeComplete is dispatched with this Sound object as the first parameter,