Difference between revisions of "* Initialisation and Core"
(One intermediate revision by the same user not shown) | |||
Line 7: | Line 7: | ||
You need to do two things to target Facebook Instant Games: | You need to do two things to target Facebook Instant Games: | ||
− | + | # Tick the Facebook Instant Game tickbox when exporting to HTML5, you can also specify the percentage indicator that the game will show it has loaded before you take control | |
− | + | # Require the FBInstant library code, see the example below | |
− | + | ||
− | You can upload, debug and test your game by creating a player and uploading to Facebook servers as a game. | + | You can upload, debug and test your game by creating a player and uploading to Facebook servers as a game. The player will interact with the Gideros Studio similar to any other player. |
− | + | ||
− | The only restriction with the player is that it only works on the computer viewing the html5 game (localhost) - this would normally rule out actual phones but there is a workaround for Android: | + | The only restriction with the player is that it only works on the computer viewing the html5 game (localhost) - this would normally rule out actual phones but there is a workaround for Android: |
− | + | ** Connect your Android phone to your computer using ADB | |
− | + | ** Type in this command in a command console shell (Windows) or terminal (Mac): | |
− | + | adb reverse tcp:15001 tcp:15001 | |
− | + | ** The Android device now will see the Gideros Studio when testing the game when a player is launched from within Facebook Messenger | |
− | + | ||
− | Please refer to the | + | Please refer to the https://developers.facebook.com/docs/games/instant-games/getting-started/quickstart original Facebook documentation for more information about testing and uploading. |
− | Please note that the offical Facebook documentation mentions having to wait for initializeAsync, with Gideros this has already been done for you before your game starts. | + | |
− | It is very important that | + | Please note that the offical Facebook documentation mentions having to wait for initializeAsync, with Gideros this has already been done for you before your game starts. |
− | FBInstant.getSDKVersion() | + | |
− | FBInstant.initializeAsync() | + | It is very important that only the following API calls are made before startGameAsync has resolved: |
− | FBInstant.getPlatform() | + | *FBInstant.getSDKVersion() |
− | FBInstant.setLoadingProgress() | + | *FBInstant.initializeAsync() |
− | FBInstant.getSupportedAPIs() | + | *FBInstant.getPlatform() |
− | FBInstant.quit() | + | *FBInstant.setLoadingProgress() |
− | FBInstant.onPause() | + | *FBInstant.getSupportedAPIs() |
− | FBInstant.player.getID() | + | *FBInstant.quit() |
+ | *FBInstant.onPause() | ||
+ | *FBInstant.player.getID() | ||
+ | |||
To help do this you could create a variable called FBInstantAPI and set it to true once startGameAsync has been resolved - then only call other API commands if FBInstant is true and then if FBInstantAPI is true. | To help do this you could create a variable called FBInstantAPI and set it to true once startGameAsync has been resolved - then only call other API commands if FBInstant is true and then if FBInstantAPI is true. | ||
− | === | + | === Example === |
'''Initialisation and removal of the Facebook loading progress indicator''' | '''Initialisation and removal of the Facebook loading progress indicator''' | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> |
Latest revision as of 05:01, 24 June 2024
Supported platforms:
Available since: Gideros 2018.3
Description
You need to do two things to target Facebook Instant Games:
- Tick the Facebook Instant Game tickbox when exporting to HTML5, you can also specify the percentage indicator that the game will show it has loaded before you take control
- Require the FBInstant library code, see the example below
You can upload, debug and test your game by creating a player and uploading to Facebook servers as a game. The player will interact with the Gideros Studio similar to any other player.
The only restriction with the player is that it only works on the computer viewing the html5 game (localhost) - this would normally rule out actual phones but there is a workaround for Android:
- Connect your Android phone to your computer using ADB
- Type in this command in a command console shell (Windows) or terminal (Mac):
adb reverse tcp:15001 tcp:15001
- The Android device now will see the Gideros Studio when testing the game when a player is launched from within Facebook Messenger
Please refer to the https://developers.facebook.com/docs/games/instant-games/getting-started/quickstart original Facebook documentation for more information about testing and uploading.
Please note that the offical Facebook documentation mentions having to wait for initializeAsync, with Gideros this has already been done for you before your game starts.
It is very important that only the following API calls are made before startGameAsync has resolved:
- FBInstant.getSDKVersion()
- FBInstant.initializeAsync()
- FBInstant.getPlatform()
- FBInstant.setLoadingProgress()
- FBInstant.getSupportedAPIs()
- FBInstant.quit()
- FBInstant.onPause()
- FBInstant.player.getID()
To help do this you could create a variable called FBInstantAPI and set it to true once startGameAsync has been resolved - then only call other API commands if FBInstant is true and then if FBInstantAPI is true.
Example
Initialisation and removal of the Facebook loading progress indicator
pcall(function() FBInstant=require "FBInstant" end)
if FBInstant then
FBInstant.startGameAsync(function()
print("Loading screen removed")
FBInstantAPI=true
end)
else
print("FBInstant not loaded")
end
MethodsFBInstant.canCreateShortcutAsync Returns whether or not the user is eligible to have shortcut creation requested. |
EventsConstants |