Javascript 我无法使用Phaser3中的create函数将任何内容加载到画布上

Javascript 我无法使用Phaser3中的create函数将任何内容加载到画布上,javascript,html,phaser-framework,Javascript,Html,Phaser Framework,我无法获取要预加载的图像 我尝试将其转换为url,尝试将文件复制到项目文件夹中的文件,并尝试仅输入文件名 function preload(){ this.load.image('sky', 'assets/sky.png'); this.load.image('ground', 'assets/platform.png'); this.load.spritesheet('dude', 'assets/dude.png'); this.load.image('star', 'as

我无法获取要预加载的图像

我尝试将其转换为url,尝试将文件复制到项目文件夹中的文件,并尝试仅输入文件名

function preload(){
  this.load.image('sky', 'assets/sky.png');
  this.load.image('ground', 'assets/platform.png');
  this.load.spritesheet('dude', 'assets/dude.png');
  this.load.image('star', 'assets/star.png');
} // preloads all of the files I will need to make the game
function create() {
  this.add.sprite(200, 200, 'star');
} // applies the files 
function update() {

}// update every frame




var config = {
  type: Phaser.AUTO,
  width: 800,
  height: 600,
  backgroundColor: '#FF0000',
  physics: {
    default: 'arcade',
    arcade: {
      gravity: {y:200},
      debug: false
    }
  },
scene: {
  preload,
  create,
  update
},

} // configures the game 

var game = new Phaser.Game(config);
我想在画布上成功地显示一个图像,但它只显示一个带有一些绿线的黑框。任何关于如何修复此问题或我缺少什么的提示都将不胜感激,谢谢

    function preload() {
      this.load.image('sky', 'file:///home/chronos/u-fc7808c01e889e74148d1013b69f0a2241def976/Downloads/testprogram-atom.js/assets/sky.png');
      this.load.image('ground', 'assets/platform.png');
      this.load.spritesheet('dude', 'assets/dude.png');
      this.load.image('star', '/home/jojobinks/Desktop/testprogram-atom.js/star.png');
    }
    function create() {
      this.add.image(0, 0, 'sky');
    }
    function update() {

    }




    var config = {
      type: Phaser.AUTO,
      width: 800,
      height: 600,
      backgroundColor: '#FF0000',
      physics: {
        default: 'arcade',
        arcade: {
          gravity: {y:200},
          debug: false
        }
      },
    scene: {
      preload,
      create,
      update
    },

    }

    var game = new Phaser.Game(config);

打开浏览器开发工具,查看网络请求。它实际上是在加载文件吗?或者你有404个错误?此外,您不能从
文件加载://
,您的游戏必须从web服务器运行。如果您只是在浏览器中打开index.html,它将无法工作。请按照Phaser网站上的入门指南了解更多详细信息