PokiSDK: Godot
Integrating the Poki SDK in Godot: the same five event moments as every engine, with Godot-specific setup.
Integration outline
- Set up the SDK for Godot. Add the Poki SDK integration for Godot web exports.
- Signal loading: fire
gameLoadingFinished()when your game is done loading, so conversion to play is measured correctly. - Gameplay events: fire
gameplayStart()on the player's first input and every return to gameplay;gameplayStop()on every interruption (pause, level end, game over, menu). - Ads: implement
commercialBreak()at natural breaks before returning to gameplay, andrewardedBreak()for opt-in rewards. Mute audio and disable input during ads. - Test with the Poki Inspector to verify the event flow.
Event rules and the full order-of-events reference live in the SDK overview.
Made by vkrishna.
This plugin works for Godot 3.4 and above. It helps you integrate the PokiSDK into your Godot (3.4.x) game. You can build the integration yourself by creating a custom HTML shell from the default template, but this plugin makes it faster and easier.
What the plugin provides
- An export preset for the Poki platform
- A custom HTML shell
- A PokiSDK singleton for GDScript integration
- A demo scene showcasing usage
Once you install the plugin and reload the project, a new HTML5 export preset called Poki appears. It provides the core integration through a custom HTML shell, and you can make API calls through the autoloaded PokiSDK singleton. See the example in the /example directory.
GDScript API and signals
- PokiSDK.gameplayStart() #-- in JS : PokiSDK.gameplayStart()
- PokiSDK.gameplayStop() #-- in JS : PokiSDK.gameplayStop()
- PokiSDK.commercialBreak() #-- in JS : PokiSDK.commercialBreak()
- PokiSDK.rewardedBreak() #-- in JS : PokiSDK.rewardedBreak()
- PokiSDK.shareableURL(params) #-- in JS : PokiSDK.shareableURL({}).then(url => {})
#Signals available from the PokiSDK
#Triggered as soon as the commercial break is over.
commercial_break_done()
#Triggered once the rewarded break has finished. Response indicates if the ad was successfully played or not.
rewarded_break_done(response)
#Triggered once the shareableURL is ready for use.
shareable_url_ready(url)Install the plugin
There are several ways to install the plugin. To install from the official Asset Library, follow the on-screen steps. Alternatively, download the archive directly from godot-poki-sdk-master.zip. Or download the source and copy the poki-sdk directory into your project's addons directory.
git clone https://github.com/vkbsb/godot-poki-sdk.gitExport your project
Enable the plugin from Project > Plugins, then reload the project via Project > Reload Current Project. Once installed, export your preset via Project > Export... and choose Poki from the presets. The extension:
- Adds a new preset called
Pokito the export config in your project. - Adds an automatically loaded singleton called
PokiSDKfor your game script to use.
Gameplay events
Use gameplayStart() to mark when players are playing your game (for example level start and unpause). Use gameplayStop() to mark when they aren't (for example level finish, game over, pause, or quit to menu).
# first level loads, player clicks anywhere
PokiSDK.gameplayStart()
# player is playing
# player loses round
PokiSDK.gameplayStop()
# game over screen pops upcommercialBreak
Commercial breaks show video ads and should be triggered at natural breaks in your game. Throughout the game we recommend calling commercialBreak() before every gameplayStart(), that is, whenever the player has shown intent to continue playing.
# register callback to respond to commercial break playback
PokiSDK.connect("commercial_break_done", self, "on_commercial_break_done")
# trigger pause gameplay event.
PokiSDK.gameplayStop()
# trigger the commercial break
PokiSDK.commercialBreak()
# callback function to handle the commercial break response
func on_commercial_break_done(response):
print("Commercial break done", response)
PokiSDK.gameplayStart()commercialBreak() will trigger an ad. Poki's system decides when a player is ready for another ad, so feel free to signal as many commercial break opportunities as possible.rewardedBreak
Rewarded breaks let a player choose to watch a rewarded video ad in exchange for a benefit in the game (more coins, for example). When using rewardedBreak(), make it clear to the player beforehand that they're about to watch an ad.
# register callback to respond to rewarded break playback
PokiSDK.connect("rewarded_break_done", self, "on_reward_break_done")
# trigger pause gameplay event
PokiSDK.gameplayStop()
# trigger the rewarded break
PokiSDK.rewardedBreak()
# callback function to handle the reward break response
func on_reward_break_done(response):
print("Rewarded break done", response)
if response:
print("Reward gained!")
else:
print("No Reward.")
PokiSDK.gameplayStart()rewardedBreak() affects the timing of commercialBreak(): when a player interacts with a rewarded break, our system's ad timer is reset so they don't immediately see another ad.Final steps
Disable sound and input during ads
Make sure audio and keyboard input are disabled during commercial breaks so the game doesn't interfere with the ad. You can pause the audio like this:
//$AudioStreamPlayer.stream_paused = trueShareable URLs and URL manipulation
You can create a shareable URL with the following:
# register callback to respond
PokiSDK.connect("shareable_url_ready", self, "on_shareable_url_ready")
# call the function with some data to encode
PokiSDK.shareableURL({"a":1, "b":2})
# implement the callback function
func on_shareable_url_ready(url):
print("URL: ", url)
$Label.text = urlUpload and test your game in Poki for Developers
Congratulations, you've implemented the PokiSDK. Now upload your game to the Poki Inspector and test it there. When you're happy with the implementation, send us a review request and we'll play the game. If you get stuck, reach out via Discord or developersupport@poki.com.