phaserjs / phaser

Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
https://phaser.io
MIT License
37.12k stars 7.1k forks source link

Feature Request - Phaser.Sound.fadeInOnDecode() #2914

Closed hdodov closed 7 years ago

hdodov commented 7 years ago

Trying to play() a sound before it has decoded will make Phaser wait for it to decode and then play it. However, the fadeIn() method doesn't do that and if you try to fade a sound that is currently being decoded, it never plays or fades.

My suggestion is to have a method that waits for the decoding and then fades the sound, or just a flag on the fadeIn() method that is used to determine whether the sound should fade after decoding or not play at all.

Currently, I'm using this and it works wonderfully:

Phaser.Sound.prototype.fadeInOnDecode = function (duration, loop, marker) {
    if (this.isDecoding) {
        this.onDecoded.add(function () {
            this.fadeIn(duration, loop, marker);
        }, this);
    } else {
        this.fadeIn(duration, loop, marker);
    }
};
photonstorm commented 7 years ago

Thank you for taking the time to open this issue. However, official support for Phaser 2 has now ended as we focus on preparing Phaser 3 for beta release. In a bid to keep the project tidy, and avoid confusion, we are closing all v2 related issues.

This does not mean your issue won't be looked-at. In November 2016 the Phaser CE (Community Edition) project began. The aim of Phaser CE was to allow the community to continue v2 development. Since then it has gained significant traction, with many updates and releases.

If you are still interested in having your issue investigated we strongly recommend testing the latest Phaser CE release. And only if the problem persists, opening an issue on the Phaser CE repo.