Skip to content

Cocos

Info

This SDK is in beta and still under development.

Requirements

When integrating the CrazyGames SDK, make sure to follow our requirements. They will help you use the SDK in the best way possible and guide you in terms of ad placements and account integration.

Installation

Download the Cocos SDK.

Right-click on the assets folder in the Assets panel and select Import Asset Package.

Import step 1

Be sure all the files are selected and click Import.

Import step 2

You can now open the CrazySDK/CrazySDKDemo scene to view the functionality of the SDK.

Demo scene

To use the SDK, import it into your files:

import CrazySDK from "./CrazySDK";

Development

Before using the SDK, please ensure the current platform is supported:

CrazySDK.isSupportedPlatform;

The supported platforms are the mobile and desktop browsers.

Initialization

Manual initialization

The new SDK requires initialization before being used. This can be done by calling the init method:

await CrazySDK.init();

It is important to await for the initialization since it happens asynchronously, and the SDK is unusable until initialized. We recommend that you do this before the game starts, for example on the loading screen.

To help you, we also created a demo loading scene, called CrazySDKDemoLoadScene. Ensure this is the first scene loaded in your game, and also provide a next scene name to the script. It will wait for the SDK initialization, and then redirect to the next scene.

Demo load scene

Environments

On localhost or 127.0.0.1 the SDK starts into local mode. This will do the following things:

  • The calls to request rewarded and midgame videos will display an overlay text.
  • SDK console logging will be enabled.
  • Requesting user data will return some demo date.
  • Only demo banners will be displayed.

If you want to enforce the local mode on other domain/ip, you can do it by appending the ?useLocalSdk=true query parameter to the URL in your browser.

On CrazyGames domains, the SDK will work as expected.

On any other domains the SDK is disabled. This means all the method calls to the SDK will throw errors about the SDK beeing disabled. To prevent this, we recommend that you check if the SDK environment is not disabled before calling any functionality:

CrazySDK.environment;