微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

相位器框架的问题,在 xampp 上运行服务器,出现错误,javascript/html

如何解决相位器框架的问题,在 xampp 上运行服务器,出现错误,javascript/html

所以我有这段代码可以运行一个游戏,这是该游戏的基础。它使用移相器。 我试图在 htdocs/itw/test.html 上的 xampp 上运行它 2 个 png 和 json 文件位于 htdocs/itw/assets/

png 是tilesets 和json tilemap

但我在控制台执行 indext.html 时遇到此错误

enter image description here

任何帮助都会很棒

<!DOCTYPE html>
<html>
<head>
    <script src="https://cdn.jsdelivr.net/npm/phaser@3.15.1/dist/phaser-arcade-physics.min.js"></script>
</head>
<body>

    <script>
        const config = {
            type: Phaser.AUTO,// Which renderer to use
            width: 800,// Canvas width in pixels
            height: 600,// Canvas height in pixels
            parent: "game-container",// ID of the DOM element to add the canvas to
            scene: {
              preload: preload,create: create,update: update
            }
          };
          
          const game = new Phaser.Game(config);
          
          function preload() {
            // Runs once,loads up assets like images and audio
            this.load.image("quadrados1","../assets/outside.png");
            this.load.image("quadrados2","../assets/outside2.png");            
            this.load.tilemapTiledJSON("mapa","../assets/fcul_map.json");
          }
          
          function create() {
            // Runs once,after all assets in preload are loaded
            const map = this.make.tilemap({ key: "mapa" });
            const tileset = map.addTilesetimage("outside","quadrados1");
            const belowLayer = map.createStaticLayer("Below Player",tileset,0);
            const worldLayer = map.createStaticLayer("World",0);
            const aboveLayer = map.createStaticLayer("Above Player",0);
          }
          
          function update(time,delta) {
            // Runs once per frame for the duration of the scene
          }
    </script>

</body>
</html>

解决方法

.. 代表父目录。尝试在加载语句中删除它们

例如。 ../assets/outside.pngassets/outside.png

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。