这是我第一次在 Phaser (3.60.0) 游戏中添加音频,因此我可能有一个明显的错误,但当我在线搜索时,我找不到解决我的问题的答案。Firefox 控制台的错误是:
Uncaught Error: Audio key "backgroundMusic" missing from cache
并由这一行触发:
//create functuon:
const backgroundMusic = this.sound.add('backgroundMusic');
this.backgroundMusic.loop = true;
this.backgroundMusic.play();
其他一些可能有用的信息:
//preload function:
this.load.audio('backgroundMusic', '.\music\backgroundMusic.mp4');
//config:
const config = {
type: Phaser.AUTO,
width: 500,
height: 500,
physics: {
default: 'arcade',
arcade: {
debug: false
}
},
scene: {
preload,
create,
update
}
};
我需要更改或添加什么才能使错误消失?