Merge pull request #991 from ericrosenbaum/bugfix/clones-share-activesoundplayers

Clones share their parent’s activeSoundPlayers object
This commit is contained in:
Eric Rosenbaum 2018-03-22 16:49:04 -04:00 committed by GitHub
commit 4e3c5c7f2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -152,6 +152,13 @@ class RenderedTarget extends Target {
this.audioPlayer = null; this.audioPlayer = null;
if (this.runtime && this.runtime.audioEngine) { if (this.runtime && this.runtime.audioEngine) {
this.audioPlayer = this.runtime.audioEngine.createPlayer(); this.audioPlayer = this.runtime.audioEngine.createPlayer();
// If this is a clone, it gets a reference to its parent's activeSoundPlayers object.
if (!this.isOriginal) {
const parent = this.sprite.clones[0];
if (parent && parent.audioPlayer) {
this.audioPlayer.activeSoundPlayers = parent.audioPlayer.activeSoundPlayers;
}
}
} }
} }