首页 > 解决方案 > Facebook Instant Games 卡在 0% 加载

问题描述

我有一个超级简单的 HTML5 游戏,我正在尝试在 facebook 嵌入式播放器中进行测试,但游戏总是卡在 0% 的加载状态,并且它没有记录我一开始的“测试”这个词,这意味着它甚至没有初始化。这是为什么?

https://www.facebook.com/embed/instantgames/YOUR_GAME_ID/player?game_url=https://localhost:8080

我已将 GAME_ID 替换为我的

索引.html

<script>

      FBInstant.initializeAsync().then(function() {
            console.log("test");
            var progress = 0;
            var interval = setInterval(function () {

                progress+=3;
                FBInstant.setLoadingProgress(progress);

            } , 100);

      FBInstant.startGameAsync()
          .then(function() {
          // Retrieving context and player information can only be done
          // once startGameAsync() resolves

          var playerName = FBInstant.player.getName();
          var playerPic = FBInstant.player.getPhoto();
          var playerId = FBInstant.player.getID();

          // Once startGameAsync() resolves it also means the loading view has 
          // been removed and the user can see the game viewport

          game.start();
      });
    });
</script>

标签: javascripthtmlfacebookfacebook-instant-games

解决方案


变量“游戏”似乎有问题。我找不到它是从哪里开始的。当我用“游戏”暂时禁用命令并且它不再停留在 0% 时。尝试调试该变量,您可能会解决问题。


推荐阅读