Icon 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 Icon ad ※ For Android
Implement the program to display Icon ads into the source file of Cocos2d-x.
Please follow the instruction below.
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 of it)Parts from the header file
#include "HelloWorldScene.h"
#include "NendIconModule.h"
USING_NS_CC;
CCScene* HelloWorld::createScene() {
...
}
Call Displaying Ad Process
Select Displaying ad methods.
Please follow the instruction below
- Create NADIconLoader (
createNADIconLoader
method) - Crete Icon (
createNADIconView
method) - Loading Ads (
load
method)
ver1.2.1 and after
When you would like to display multiple icon 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 for the details.
The ad placements are different depends on the method you call when you generate the icon.
Method | Explanation |
---|---|
createNADIconView | Select and the ad placement |
createNADIconViewBottom | Place the ad on the bottom center of the screen. |
createNADIconViewTop | Place the ad on the upper center of the screen. |
Please refer to The Contents of NendIconModule for the details of each method.
Ex.) 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 ad on upper center
char iconApiKey[] = "apiKey published on dashboard";
char iconSpotID[] = "spotID published on dashboard";
NendIconModule::createNADIconLoader(iconApiKey, iconSpotID);
NendIconModule::createNADIconViewTop();
NendIconModule::load();
return true;
}
Set the Title Line (added ver1.2.1)
To set the title line under the Icon, please follow the instruction.
Display/hide
Select true
/false
on the bool
section
bool | Explanation |
---|---|
true | Display the title line. |
false | Hide the title line. |
Ex.) Displaying the title line
NendIconModule::createNADIconViewTop("spotID published on dashboard", true, true, Color3B::BLACK);
Ex.) Hiding the title line
NendIconModule::createNADIconViewTop("spotID published on dashboard", false, true, Color3B::BLACK);
Select the text color
The default text color is black.
Set the color on the structure of color3B
which can use after cocos2dx-v3.0.
Select from Color3B
or 10 numbers of RGB.
Default (Black)
NendIconModule::createNADIconViewTop();
Title line in white
NendIconModule::createNADIconViewTop("spotID published on dashboard", true, true, Color3B::WHITE);
or
NendIconModule::createNADIconViewTop("spotID published on dashboard", true, true, Color3B(255, 255, 255));
Set the Space (added ver1.2.1)
Select true/false
on the bool
section.
Please select true
(default) when you need space, false
when you don’t.
bool | Explanation |
---|---|
true | Display Icon with a space. |
false | Display Icon without a space. |
Ex.) Display Icon with a space.
NendIconModule::createNADIconViewTop("spotID published on dashboard", true, true, Color3B::BLACK);
Ex.) Display Icon without a space.
NendIconModule::createNADIconViewTop("spotID published on dashboard", true, false, Color3B::BLACK);