initialize audio player once per sprite (not for clones)

This commit is contained in:
Eric Rosenbaum 2017-01-06 16:14:27 -05:00
parent 9980f4da3f
commit b88c6c96e2

View file

@ -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;
}
};
/**