PokiSDK - Defold
Made by Alexey Gulev / PotatoJam
Introduction & Features
This is a Poki Plugin made for the Defold Engine.
The Lua API here corresponds to the original Javascript API:
Lua vs Javascript
poki_sdk.gameplay_start() -- in JS it's PokiSDK.gameplayStart()
poki_sdk.gameplay_stop() -- in JS it's PokiSDK.gameplayStop()
poki_sdk.commercial_break(function(self)end) -- in JS it's PokiSDK.commercialBreak()
poki_sdk.rewarded_break(function(self, success)end) -- in JS it's PokiSDK.rewardedBreak()
poki_sdk.happy_time(value) -- in JS it's PokiSDK.happyTime(value), where value is between 0 and 1
poki_sdk.shareable_url(params, callback) -- in JS it's PokiSDK.shareableURL({}).then(url => {})
local value = poki_sdk.get_url_param(key) -- in JS it's PokiSDK.getURLParam('id')
1. Initialize the SDK
First, you must add this project as a Defold library dependency. In order to do so, open your game.project
file and add the following file to Project > Dependencies
:
- PokiSDK Defold Plugin
- Or point to the ZIP file of a specific release.
The plugin takes care of the loading events on its own, so you don’t need to fire our loading events manually.
2. Implement the gameplay events
Use the gameplayStart() event to describe when users are playing your game (e.g. level start and unpause).
Use the gameplayStop() event to describe when users aren’t playing your game (e.g. level finish, game over, pause, quit to menu).
-- first level loads, player clicks anywhere
poki_sdk.gameplay_start()
-- player is playing
-- player loses round
poki_sdk.gameplay_stop()
-- game over screen pops up
3. Implement commercialBreak
Commercial breaks are used to display video ads and should be triggered on natural breaks in your game. Throughout the rest of your game, we recommend you implement the commercialBreak() before every
gameplayStart() , i.e. whenever the user has shown an intent to continue playing.
Important information about commercialBreaks
Not every single commercialBreak() will trigger an ad. Poki’s system will determine when a user is ready for another ad, so feel free to signal as many commercial break opportunities as possible.
4. Implement rewardedBreak
Rewarded breaks allow for a user to choose to watch a rewarded video ad in exchange for a certain benefit in the game (e.g. more coins, etc.). When using rewardedBreak() , please make it clear to the player beforehand that they’re about to watch an ad.
About the rewardedBreak timer
rewardedBreak() affects the timing of
commercialBreak() - When a user interacts with a rewarded break, our systemโs ad timer is reset to ensure the user does not immediately see another ad.
Final Steps
Disable sound and input during ads
Make sure that audio and keyboard input are disabled during commercialBreaks, so that the game doesn’t interfere with the ad:
-- gameplay stops
-- fire your mute audio function
poki_sdk.commercial_break(function(self)
-- fire your unmute audio function
-- fire your function to continue to game
end)
Upload and test your game in Poki for Developers
Congrats, youโve successfully implemented the PokiSDK! Now upload your game to Poki for Developers and test it in our QA Tool. When you’re happy with the implementation, send us a review request and we’ll play the game. Feel free to contact us via Discord or developersupport@poki.com
if you’re stuck.