Note: This extension works for CocosCreator3.4.0 and above only
This extension is designed to help the integration of the PokiSDK into your Cocos Creator(3.x) game. You can create a custom build and preview templates to do the integration by yourself, but the extension provides them ready to use.
The extension provides:
- A preview template
- A web-mobile build template
- PokiSDK abstraction
- A demo scene showcasing usage
Once you install and enable the extension, you will be able to test the PokiSDK integration in preview mode (in browser) and be able to make builds (web-mobile) that can be uploaded to poki platform.
Please note that Poki is a curated platform, you will need to submit your game through pokifordevelopers.com first, and only work on the sdk integration after the game is approved .
There are two ways to download and install the extension
You can search and install the extension directly from the Cocos store. This is the easiest way to get started. //screenshots of the store and install process.
Download the extension archive poki-sdk-v1.2.2.zip.
Or download the source code as a zip file.
git clone https://github.com/vkbsb/cocos-creator-poki-sdk
- Once this is done, you can launch the extension manager in Cocos creator editor
- Switch to the project tab and click on add extension button
- Browse to the poki-sdk-v1.2.2.zip file you have downloaded and click open.
Once you have done the installation, go to the extension manager and ensure that the poki-build extension is enabled.
- Open the extension manager
- Under project tab, ensure that poki-sdk is enabled. If it's not enabled, enable it.
The extension creates the following files in your project directory.
- preview-template/index.ejs
- build-templates/common/application.ejs
- build-templates/web-mobile/index.ejs
- assets/poki-api/PokiPlatform.ts
- assets/demo/demo.scene
- assets/demo/DemoScript.ts
In your component scripts, you will be able to import CCPokiSDK and use it to interact with the PokiSDK. The following are the functions that are available for you to use from your game scripts. Checkout the DemoScript.ts for example usage.
CCPokiSDK.isAdBlocked() //-- in JS it's PokiSDK.isAdBlocked()
CCPokiSDK.gameplayStart() //-- in JS it's PokiSDK.gameplayStart()
CCPokiSDK.gameplayStop() //-- in JS it's PokiSDK.gameplayStop()
CCPokiSDK.commercialBreak() //-- in JS it's PokiSDK.commercialBreak()
CCPokiSDK.rewardBreak() //-- in JS it's PokiSDK.rewardedBreak()
CCPokiSDK.shareableURL(params, callback) //-- in JS it's PokiSDK.shareableURL({}).then(url => {})
local value = CCPokiSDK.getURLParam(key) //-- in JS it's PokiSDK.getURLParam('id')
You will notice that you do not see an equivalent to PokiSDK.setDebug(value)
this is because the extension sets this automatically based on the build you make.
________________________________________________________
| Build Type | PokiSDK Debug |
|_____________________________|_________________________|
| Preview Build | PokiSDK.setDebug(true) |
| web-mobile:Debug(checked) | PokiSDK.setDebug(true) |
| web-mobile:Debug(un-checked)| PokiSDK.setDebug(false)|
---------------------------------------------------------
Rewarded Break
This ad type is used for optional rewarded actions, for example watching an ad video in exchange for in-game currency, a revive, a level skip... Here are the following steps you need to follow to implement it using this extension.
- Register for a call back on
cc.game
forEVENT_REWARD_BREAK_DONE
- if
arguments[0] == true
we can give player reward, else don't reward.
Check out DemoScript.ts for reference.
SiteLock
Poki provides a sitelock code to the developers which helps ensure that the game is playable only on Poki's website. Please collect it from your dev contact. Once you get it, paste the code in the SiteLock
field of the poki-sdk
section of the web-mobile
build.
Please note that the sitelock code is embedded in the build only when you make a build with debug box un-checked.
Submit your game on Poki
On developers.poki.com you can submit your game with Poki. If we think your game is a good fit for our playground, we will reach out to you!