Skip to content

Poki Extension for Cocos Creator 3.x

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 Poki for Developers first, and only work on the sdk integration after the game is approved .

1.Installation

There are two ways to download and install the extension

Cocos Store

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.

From Source/Release

Download the extension archive poki-sdk-v1.2.zip.

Or download the source code as a zip file.

git clone https://github.com/vkbsb/cocos-creator-poki-sdk
  1. Once this is done, you can launch the extension manager in Cocos creator editor extension-manager-open
  2. Switch to the project tab and click on add extension button extension-add
  3. Browse to the poki-sdk-v1.2.zip file you have downloaded and click open. pick-extension-archive

2.Enable extension

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 the platform through Poki for Developers.

  1. Open the extension manager

extension-manager-open

  1. Under project tab, ensure that poki-sdk is enabled. If it's not enabled, enable it.

extension-enable

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

folders-created

3.Usage

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 for EVENT_REWARD_BREAK_DONE
- if arguments[0] == true we can give player reward, else don't reward.

Check out DemoScript.ts for reference.

Site Lock

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.

SiteLock Code

Please note that the sitelock code is embedded in the build only when you make a build with debug box un-checked.

Web-mobile-release