Calling gameStarted in a game that doesn't load any assets would cause the error {code: "INVALID_OPERATION", message: "Can not perform this operation before game start."}. The plugin will now has a new internal method gameStartedHandler and will redirect the flow accordingly based on asset loading. Fix #4550

This commit is contained in:
Richard Davey 2019-09-26 13:20:59 +01:00
parent 163ab4fc19
commit 82401fc74f
2 changed files with 23 additions and 1 deletions

View file

@ -5,6 +5,7 @@
### Facebook Instant Games Plugin
* Calling `showAd` or `showVideoAd` will now check to see if the ad has already been displayed, and skip it when iterating the ads array, allowing you to display an ad with the same Placement ID without preloading it again. Fix #4728 (thanks @NokFrt)
* Calling `gameStarted` in a game that doesn't load any assets would cause the error `{code: "INVALID_OPERATION", message: "Can not perform this operation before game start."}`. The plugin will now has a new internal method `gameStartedHandler` and will redirect the flow accordingly based on asset loading. Fix #4550 (thanks @bchee)
### New Features

View file

@ -387,7 +387,7 @@ var FacebookInstantGamesPlugin = new Class({
{
this.hasLoaded = true;
FBInstant.startGameAsync().then(this.gameStarted.bind(this));
FBInstant.startGameAsync().then(this.gameStartedHandler.bind(this));
}
}, this);
@ -408,6 +408,27 @@ var FacebookInstantGamesPlugin = new Class({
* @since 3.13.0
*/
gameStarted: function ()
{
if (!this.hasLoaded)
{
this.hasLoaded = true;
FBInstant.startGameAsync().then(this.gameStartedHandler.bind(this));
}
else
{
this.gameStartedHandler();
}
},
/**
* The internal gameStarted handler.
*
* @method Phaser.FacebookInstantGamesPlugin#gameStartedHandler
* @private
* @since 3.20.0
*/
gameStartedHandler: function ()
{
var APIs = FBInstant.getSupportedAPIs();