Displaying Multiple Ads - 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.
Instruction
Ad placement
Ex.) Add header file
When you would like to display banner and icon in the same file(.cpp), since there is no Icon Module for iOS after ver1.2.0, please branch off from header include as below.
#include "NendModule.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include "NendIconModule.h" // only for Android
#endif
Ex.) Displaying banner ad and Icon ad at the same time
When you would like to display banner and icon in the same file(.cpp), since there is no Icon Module for iOS after ver1.2.0, please branch off as below.
bool HelloWorld::init()
{
...
// add the sprite as a child to this layer
this->addChild(pSprite, 0);
// Banner
char apiKey[] = "a6eca9dd074372c898dd1df549301f277c53f2b9";
char spotID[] = "3172";
NendModule::createNADViewTop(apiKey, spotID);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
// Icon *only for Android
char iconApiKey[] = "0c734134519f25412ae9a9bff94783b81048ffbe";
char iconSpotID[] = "101282";
NendIconModule::createNADIconLoader(iconApiKey, iconSpotID);
NendIconModule::createNADIconViewTop();
NendIconModule::load();
#endif
return true;
}
Ex.) Displaying multiple banner ads at the same time
bool HelloWorld::init()
{
...
// add the sprite as a child to this layer
this->addChild(pSprite, 0);
// Display banner ad on the top center
char apiKey_A[] = "apiKey published on dashboard";
char spotID_A[] = "spotID published on dashboard";
NendModule::createNADViewTop(apiKey_A, spotID_A);
// display different ad on the bottom center
char apiKey_B[] = "apiKey published on dashboard";
char spotID_B[] = "spotID published on dashboard";
NendModule::createNADViewBottom(apiKey_B, spotID_B);
return true;
}
Ex.) Displaying multiple icon ads at the same time
bool HelloWorld::init()
{
...
// add the sprite as a child to this layer
this->addChild(pSprite, 0);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
// displaying icon ad on the upper center
char iconApiKey_A[] = "apiKey published on dashboard";
char iconSpotID_A[] = "spotID published on dashboard";
NendIconModule::createNADIconLoader(iconApiKey_A, iconSpotID_A);
NendIconModule::createNADIconViewTop(iconSpotID_A, true, true, Color3B::BLACK);
NendIconModule::load(iconSpotID_A);
// display icon ad on the bottom center of the screen
char iconApiKey_B[] = "apiKey published on dashboard";
char iconSpotID_B[] = "spotID published on dashboard";
NendIconModule::createNADIconLoader(iconApiKey_B, iconSpotID_B);
NendIconModule::createNADIconViewBottom(iconSpotID_B, true, true, Color3B::BLACK);
NendIconModule::load(iconSpotID_B);
#endif
return true;
}