Skip to content

Commit 74bee32

Browse files
committed
Sound.fadeIn now supports fading from a marker, as well as the entire audio clip, so now works with audio sprites (thanks @vorrin phaserjs#1413)
1 parent 6506e8d commit 74bee32

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ Thanks to @pnstickne for vast majority of this update.
124124
* 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.
125125
* World.setBounds will now adjust the World.x/y values to match those given (#1555)
126126
* ArcadePhysics.distanceToPointer now calculates the distance in world space values.
127+
* Sound.fadeIn now supports fading from a marker, as well as the entire audio clip, so now works with audio sprites (thanks @vorrin #1413)
127128

128129
### Bug Fixes
129130

src/sound/Sound.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -840,28 +840,31 @@ Phaser.Sound.prototype = {
840840
/**
841841
* Starts this sound playing (or restarts it if already doing so) and sets the volume to zero.
842842
* Then increases the volume from 0 to 1 over the duration specified.
843+
*
843844
* At the end of the fade Sound.onFadeComplete is dispatched with this Sound object as the first parameter,
844845
* and the final volume (1) as the second parameter.
845846
*
846847
* @method Phaser.Sound#fadeIn
847848
* @param {number} [duration=1000] - The time in milliseconds over which the Sound should fade in.
848849
* @param {boolean} [loop=false] - Should the Sound be set to loop? Note that this doesn't cause the fade to repeat.
850+
* @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 `''`.
849851
*/
850-
fadeIn: function (duration, loop) {
852+
fadeIn: function (duration, loop, marker) {
851853

852854
if (typeof loop === 'undefined') { loop = false; }
855+
if (typeof marker === 'undefined') { marker = this.currentMarker; }
853856

854857
if (this.paused)
855858
{
856859
return;
857860
}
858861

859-
this.play('', 0, 0, loop);
862+
this.play(marker, 0, 0, loop);
860863

861864
this.fadeTo(duration, 1);
862865

863866
},
864-
867+
865868
/**
866869
* Decreases the volume of this Sound from its current value to 0 over the duration specified.
867870
* At the end of the fade Sound.onFadeComplete is dispatched with this Sound object as the first parameter,

0 commit comments

Comments
 (0)