From b88c6c96e270c4e66e947e50c8d56268b604e351 Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum Date: Fri, 6 Jan 2017 16:14:27 -0500 Subject: [PATCH] initialize audio player once per sprite (not for clones) --- src/sprites/rendered-target.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/sprites/rendered-target.js b/src/sprites/rendered-target.js index ee7c9b73a..881d1d2cc 100644 --- a/src/sprites/rendered-target.js +++ b/src/sprites/rendered-target.js @@ -46,16 +46,6 @@ var RenderedTarget = function (sprite, runtime) { brightness: 0, ghost: 0 }; - - /** - * Audio player - */ - this.audioPlayer = null; - if (this.runtime) { - this.audioPlayer = this.runtime.audioEngine.createPlayer(); - this.audioPlayer.loadSounds(this.sprite.sounds); - } - }; util.inherits(RenderedTarget, Target); @@ -72,6 +62,18 @@ RenderedTarget.prototype.initDrawable = function () { 'control_start_as_clone', null, this ); } + + /** + * Audio player + */ + this.audioPlayer = null; + if (this.runtime) { + if (this.isOriginal) { + this.sprite.audioPlayer = this.runtime.audioEngine.createPlayer(); + this.sprite.audioPlayer.loadSounds(this.sprite.sounds); + } + this.audioPlayer = this.sprite.audioPlayer; + } }; /**