Skip to content

Commit 9d58297

Browse files
committed
Button.setSounds now works if given an AudioSprite as the sound source.
1 parent 1a357e1 commit 9d58297

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ Version 2.1.3 - "Ravinda" - in development
104104
* Fixed the Filter mouse uniform value population.
105105
* Fixed an issue where audio files with query strings after them would fail the `canPlayAudio` checks (thanks Vithar)
106106
* Input.hitTest now accurately detects hits on the extreme edges of a display object (thanks InsaneHero)
107+
* Button.setSounds now works if given an AudioSprite as the sound source.
107108

108109
For details about changes made in previous versions of Phaser see the full Change Log at https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md
109110

src/gameobjects/Button.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,13 @@ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame, up
337337
* Call this function with no parameters at all to reset all sounds on this Button.
338338
*
339339
* @method Phaser.Button.prototype.setSounds
340-
* @param {Phaser.Sound} [overSound] - Over Button Sound.
340+
* @param {Phaser.Sound|Phaser.AudioSprite} [overSound] - Over Button Sound.
341341
* @param {string} [overMarker] - Over Button Sound Marker.
342-
* @param {Phaser.Sound} [downSound] - Down Button Sound.
342+
* @param {Phaser.Sound|Phaser.AudioSprite} [downSound] - Down Button Sound.
343343
* @param {string} [downMarker] - Down Button Sound Marker.
344-
* @param {Phaser.Sound} [outSound] - Out Button Sound.
344+
* @param {Phaser.Sound|Phaser.AudioSprite} [outSound] - Out Button Sound.
345345
* @param {string} [outMarker] - Out Button Sound Marker.
346-
* @param {Phaser.Sound} [upSound] - Up Button Sound.
346+
* @param {Phaser.Sound|Phaser.AudioSprite} [upSound] - Up Button Sound.
347347
* @param {string} [upMarker] - Up Button Sound Marker.
348348
*/
349349
Phaser.Button.prototype.setSounds = function (overSound, overMarker, downSound, downMarker, outSound, outMarker, upSound, upMarker) {
@@ -359,15 +359,15 @@ Phaser.Button.prototype.setSounds = function (overSound, overMarker, downSound,
359359
* The Sound to be played when a Pointer moves over this Button.
360360
*
361361
* @method Phaser.Button.prototype.setOverSound
362-
* @param {Phaser.Sound} sound - The Sound that will be played.
362+
* @param {Phaser.Sound|Phaser.AudioSprite} sound - The Sound that will be played.
363363
* @param {string} [marker] - A Sound Marker that will be used in the playback.
364364
*/
365365
Phaser.Button.prototype.setOverSound = function (sound, marker) {
366366

367367
this.onOverSound = null;
368368
this.onOverSoundMarker = '';
369369

370-
if (sound instanceof Phaser.Sound)
370+
if (sound instanceof Phaser.Sound || sound instanceof Phaser.AudioSprite)
371371
{
372372
this.onOverSound = sound;
373373
}
@@ -383,15 +383,15 @@ Phaser.Button.prototype.setOverSound = function (sound, marker) {
383383
* The Sound to be played when a Pointer moves out of this Button.
384384
*
385385
* @method Phaser.Button.prototype.setOutSound
386-
* @param {Phaser.Sound} sound - The Sound that will be played.
386+
* @param {Phaser.Sound|Phaser.AudioSprite} sound - The Sound that will be played.
387387
* @param {string} [marker] - A Sound Marker that will be used in the playback.
388388
*/
389389
Phaser.Button.prototype.setOutSound = function (sound, marker) {
390390

391391
this.onOutSound = null;
392392
this.onOutSoundMarker = '';
393393

394-
if (sound instanceof Phaser.Sound)
394+
if (sound instanceof Phaser.Sound || sound instanceof Phaser.AudioSprite)
395395
{
396396
this.onOutSound = sound;
397397
}
@@ -407,15 +407,15 @@ Phaser.Button.prototype.setOutSound = function (sound, marker) {
407407
* The Sound to be played when a Pointer presses down on this Button.
408408
*
409409
* @method Phaser.Button.prototype.setDownSound
410-
* @param {Phaser.Sound} sound - The Sound that will be played.
410+
* @param {Phaser.Sound|Phaser.AudioSprite} sound - The Sound that will be played.
411411
* @param {string} [marker] - A Sound Marker that will be used in the playback.
412412
*/
413413
Phaser.Button.prototype.setDownSound = function (sound, marker) {
414414

415415
this.onDownSound = null;
416416
this.onDownSoundMarker = '';
417417

418-
if (sound instanceof Phaser.Sound)
418+
if (sound instanceof Phaser.Sound || sound instanceof Phaser.AudioSprite)
419419
{
420420
this.onDownSound = sound;
421421
}
@@ -431,15 +431,15 @@ Phaser.Button.prototype.setDownSound = function (sound, marker) {
431431
* The Sound to be played when a Pointer has pressed down and is released from this Button.
432432
*
433433
* @method Phaser.Button.prototype.setUpSound
434-
* @param {Phaser.Sound} sound - The Sound that will be played.
434+
* @param {Phaser.Sound|Phaser.AudioSprite} sound - The Sound that will be played.
435435
* @param {string} [marker] - A Sound Marker that will be used in the playback.
436436
*/
437437
Phaser.Button.prototype.setUpSound = function (sound, marker) {
438438

439439
this.onUpSound = null;
440440
this.onUpSoundMarker = '';
441441

442-
if (sound instanceof Phaser.Sound)
442+
if (sound instanceof Phaser.Sound || sound instanceof Phaser.AudioSprite)
443443
{
444444
this.onUpSound = sound;
445445
}

0 commit comments

Comments
 (0)