Html 如何将背景图像添加到我的phaser游戏中?
我想将背景图像/场景添加到我的游戏中。这个代码不起作用Html 如何将背景图像添加到我的phaser游戏中?,html,phaser,Html,Phaser,我想将背景图像/场景添加到我的游戏中。这个代码不起作用 const config= { type: Phaser.AUTO, height: 675, width: 675, scene: { preload, create, update, } }
const config= {
type: Phaser.AUTO,
height: 675,
width: 675,
scene: {
preload,
create,
update,
}
}
const game = new Phaser.Game(config)
const gameState ={
}
function preload() {
this.load.image('background','/background.jpg');
}
function create() {
gameState.move = this.add.circle(325,325,25,'0xffffff');
let bg=this.add.image(0,0,'background');
}
function update() {
}
我能做什么?我是新的相位游戏。
我不认为URL是错误的。但这是输出:图像的URL可能不正确。用户可以说URL可以是相对的,也可以是绝对的。如果图像与JavaScript文件在文件系统中处于同一级别,则在
preload
函数中,您可以尝试:
this.load.image('background','background.jpg')代码>
或
this.load.image('background','./background.jpg')代码>