Only load BAM sound once instead of on every death

This commit is contained in:
Andrew Guibert 2018-05-15 11:01:40 -05:00
parent e048675b58
commit ee1cdd20db

View File

@ -6,6 +6,12 @@ export class Player {
// For this reason, we need to pre-load an instance of the image (this copy never gets used)
static readonly PLAYER_BITMAP = new Bitmap('../../assets/images/bike_wide.png');
static readonly PLAYER_DEAD_BITMAP = new Bitmap('../../assets/images/status_dead.png');
static readonly BAM = new Audio('../../assets/sound/bam.wav');
static initialize() {
Player.BAM.load();
}
Player.initialize();
public name: string;
public status: string;
@ -59,9 +65,7 @@ export class Player {
this.image.scaleY = 1.2;
this.image.x = this.x - 20;
this.image.y = this.y - 20;
var bam = new Audio('../../assets/sound/bam.wav');
bam.load();
bam.play();
Player.BAM.play();
}
this.status = status;
}