0

我是JavascriptPhaser的新手。我的游戏在我的虚拟主机中运行良好。我尝试添加 Instant Games SDK,但未加载资产。

我在Phaser 网站的 Phaser 3 教程中尝试过 Facebook Instant Games ,我尝试实现他们所说的,但没有任何效果;加载屏幕卡在 0%。

FBInstant.initializeAsync().then(function() {  
      let gameConfig = {
      type: Phaser.AUTO,
      backgroundColor:0x87ceeb,
      scale: {
          mode: Phaser.Scale.FIT,
          autoCenter: Phaser.Scale.CENTER_BOTH,
          parent: 'thegame',
          width: window.innerWidth,
          height: window.innerHeight
      },
      physics: {
          default: 'arcade'
      },
      scene: [preloader,welcomeGame,
              playGame,
              resumeGame,
              gameOver
              ]
  }
  game = new Phaser.Game(gameConfig);
}); 

class preloader extends Phaser.Scene{
  constructor(){
      super('Preloader');
  }

   preload() {

      this.facebook.once('startgame', this.startGame, this);
      this.facebook.showLoadProgress(this);

      this.load.image('logoBanner', '/src/img/logoBanner.png');
      //.
      //.
      //.
      //.

      this.load.audio("jump", ["/src/music/jump.ogg","/src/music/jump.mp3"]);

        }

  startGame ()
  {
      this.scene.start('WelcomeGame');
  }

4

1 回答 1

0

你需要做的很简单。加载资产后,您需要调用以下方法:

FBInstant.setLoadingProgress(100);

接着

FBInstant.startGameAsync().then(function() {
          startGame();          
        });

当然,您可以使设置 setLoadingProgress 动态。

玩得开心。

于 2019-12-31T11:52:19.973 回答