Fullscreen 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.
The Flow to Implement Fullscreen ads.
Added header file declaration
#include "NendFullBoardAd.h"
Instance generation
nend_module::NendFullBoardAd fullBoardAd = new nend_module::NendFullBoardAd("SPOT ID", "API KEY");
Load ads
fullBoardAd->load();
Display ads
fullBoardAd->show();
Note: When you close the fullscreen ads, the ad is not automatically reloaded. When updating the advertisement contents, you need to execute the loading process again.
About background color outside Safe Area
You can change the background color outside iPhoneX Safe Area more affinitive to your app looking & feeling.
Please use a cocos2d::Color4F struct to specify the color.
Examples using constant
fullBoardAd->setBackgroundColor4F(cocos2d::Color4F::WHITE);
Example using float
fullBoardAdTop->setBackgroundColor4F(cocos2d::Color4F(1.f, 1.f, 1.f, 1.f));
For more information, please check iOS wiki "About background color outside Safe Area".
Event notification (optional)
When the ad is loaded.
fullBoardAd->onFullBoardAdLoaded = [this](const nend_module::NendFullBoardAd& ad) {
log("onFullBoardAdLoaded");
};
When the ad is failed to load.
fullBoardAd->onFullBoardAdFailedToLoad = [this](const nend_module::NendFullBoardAd& ad, const nend_module::NendFullBoardAd::ErrorType error) {
log("onFullBoardAdFailedToLoad : error type");
switch (error) {
case nend_module::NendFullBoardAd::ErrorType::FAILED_TO_AD_REQUEST:
log("Failed to ad request.");
break;
case nend_module::NendFullBoardAd::ErrorType::FAILED_TO_DOWNLOAD_IMAGE:
log("Failed to download image.");
break;
case nend_module::NendFullBoardAd::ErrorType::INVALID_AD_SPACES:
log("Invalid ad spaces specified.");
break;
default:
break;
}
};
When the ad is displayed.
fullBoardAd->onFullBoardAdShown = [this](const nend_module::NendFullBoardAd& ad) {
log("onFullBoardAdShown");
};
When the ad is closed.
fullBoardAd->onFullBoardAdDismissed = [this](const nend_module::NendFullBoardAd& ad) {
log("onFullBoardAdDismissed");
};
When the ad is clicked.
fullBoardAd->onFullBoardAdClicked = [this](const nend_module::NendFullBoardAd& ad) {
log("onFullBoardAdClicked");
};