Banner Ad - fan-ADN/nendSDK-cocos2d-x GitHub Wiki

Preparation

If you have not yet register app/ad placements nor downloaded SDK, please refer to following link.

SDK Implementation

Add SDK/Module to a project.


Display Banner ad

Implement the program to display banner ads into the source file of Cocos2d-x.

Please follow the instruction below.

  1. Add header file to the source file of displaying ad scene.
  2. Call Displaying Ad Process

Add header file to the source file of displaying ad scene.

Add header file to the source file of displaying ad scene

Ex.)HelloWorldScene.cpp(part)Parts from the header file

#include "HelloWorldScene.h"
#include "NendModule.h"

USING_NS_CC;

CCScene* HelloWorld::createScene() {
...
}

Call Displaying Ad Process

Select Displaying ad methods.
The ad placements are different depend on Displaying ad methods you have selected.

Method Explanation
createNADView Select the adplacement
createNADViewBottom Place the ad on the bottom center of the screen.
createNADViewTop Place the ad on the upper center of the screen.

ver1.2.1 and after

When you would like to display multiple banner ads, select the ad space ID (apikey and spotID), and set the method from above to the each ad space ID.
Please refer to Displaying Multiple Ads.
Please refer to The Contents of NendModule to see the details for each method.

Ex.) Displaying banner ad on header.

HelloWorldScene.cpp(part of it)- HelloWorld::init()

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    ...
    // add the sprite as a child to this layer
    this->addChild(pSprite, 0);

    // example for displaying banner ad on header
    char apiKey[] = "apiKey published on dashboard";
    char spotID[] = "spotID published on dashboard";
    NendModule::createNADViewTop(apiKey, spotID);

    return true;
}

Display the banner ad by utilizing the auto scale (added from ver.1.2.0)

Please refer to the manuals for nendSDK-iOS/nendSDK-Android for more information.

Ex.) Utilize the auto scale and display the ad on the header

HelloWorldScene.cppp(part of it)- HelloWorld::init()

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    ...
    // add the sprite as a child to this layer
    this->addChild(pSprite, 0);

    char apiKey[] = "apiKey published on dashboard";
    char spotID[] = "spotID published on dashboard";
    // sets `true`
    NendModule::createNADViewTop(apiKey, spotID, true);

    return true;
}

Verification