Skip to content

Instantly share code, notes, and snippets.

@erodozer
Last active December 24, 2021 07:05
Show Gist options
  • Save erodozer/9b3c39ba4bfce6535182788c3fbeaaa8 to your computer and use it in GitHub Desktop.
Save erodozer/9b3c39ba4bfce6535182788c3fbeaaa8 to your computer and use it in GitHub Desktop.
Godot Instant Games on Facebook
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<meta name='viewport' content='width=device-width, user-scalable=no' />
<title>fb-instant-godot</title>
</head>
<body>
<canvas id='canvas'></canvas>
<script src="https://connect.facebook.net/en_US/fbinstant.7.0.js"></script>
<script src="$GODOT_URL"></script>
<script type='text/javascript'>
const engine = new Engine($GODOT_CONFIG);
(async function() {
await FBInstant.initializeAsync();
await engine.startGame({
'onProgress': function (current, total) {
if (total > 0) {
const progress = current / (total * 1.0);
console.log(progress);
FBInstant.setLoadingProgress(progress * 100);
}
},
});
await FBInstant.startGameAsync();
})();
</script>
</body>
</html>
@erodozer
Copy link
Author

To use, simply add an HTML5 export option to your Godot project and set the custom HTML shell like so

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment