# Cocos2d-x Quick Start

This guide will show you how to integrate the Frameplay plugin into a new c++ Cocos2d-x project.

We officially support:

  • Cocos2d-x 3.17
  • Windows, Mac, Android & iOS platforms

# Prerequisites

We require you to have created a Frameplay Developer Account and to have created a "new game". We also assume that you have installed Cocos2d-x 3.17 and can run the command $cocos in the Terminal. Cocos2d-x 3.17 also required Visual Studio 2017.

# Create a Template Cocos Project

Once all of the prerequisites have been met, you can quickly create a new template c++ cocos project by running the following command. This command will create a com.company.cocos folder containing the new project. Make note of where this folder has been created in the Terminal.

cocos new -l cpp com.company.cocos -d ./

# Download and Install the Frameplay Plugin

  1. Download the latest version of the Frameplay Cocos2d-x plugin from the downloads page (opens new window)
  2. Unzip the plugin, then copy the Frameplay and Resources folder into your project's root directory. In this example, that would be inside the com.company.cocos folder.

Our Resources folder will merge with the one already existing inside com.company.cocos

# Update Template Project Files

Once the template c++ project has been created we need to edit some files before we'll see ads in builds. Start by:

  1. Include FrameplayExampleScene.h at the top of the Classes\AppDelegate.cpp
#include "AppDelegate.h"
#include "Frameplay/FrameplayExampleScene.h"

Depending on the IDE you are using you will likely run into some sort of "FrameplayExampleScene.h not found" error. We cover this setup for some Operating Systems and IDEs in the next step.

  1. In the same file, instead of calling HelloWorld::createScene(), call FrameplayExampleScene::create()
// create a scene. it's an autorelease object
// auto scene = HelloWorld::createScene();
auto scene = FrameplayExampleScene::create();
  1. Jump to Frameplay\FrameplayExampleScene.h and change the game_id parameter to the one you setup HERE (opens new window)
// Place your game id here
const char* const game_id = "YOUR_GAME_ID";

Once complete, build and run your Cocos2d-x application. You should see 4 Ad Spaces that will load "mock" advertisements. If there are any issues, check the Visual Studio logs for deatils and visit our FAQ page

For more information on what's happening inside the FrameplayExampleScene.h, and to implement your own version, see the Ad Spaces Docs and the Session & Cameras Docs

# Configure Project Properties & Build!

There are many different project configurations depending on the Operating Sytem / IDE you are using. Please jump to one of the following links that suits your needs. After these steps are complete, you should have a build on any plaform displaying mock ads.

# Packaging Builds

  1. When building for production, set the frameplay::sdk_mode parameter to release when initializing the SDK (see step # Initialize the Frameplay SDK). This will ensure your Ad Spaces request real advertisements and analytics will be recorded on your Production Dashboard
const frameplay::sdk_configuration config{
  1. Confirm you have submitted your account and game for approval on the Frameplay Platform:

Please allow 48 hours for approval. Advertisements will not load in Production builds until both your account and game is approved.

At this time our integration team will contact you and notify once approved.

# Best Practices

We highly recommend you check out the Best Practices Guide to maximize revenue, impression quality and user experience!

# Troubleshooting

If something went wrong during setup, check and logs for deatils and visit our FAQ page.

Last Updated: 7/5/2022, 11:26:50 PM