Ads in cocos2d-x app

Ads in cocos2d-x app
0.0 0



How I can use ads in my application?

I tried to rework the example of Samsung:
result GameField::CreateControl(void)
result r = E_SUCCESS;
*pAd = new Ad;
r =*pAd~~>Construct, L“2100000003_001”, this);
__pAd~~>SetTextColor(Osp::Graphics::Color(255, 255, 255));
ArrayList* pKeywordsList = new ArrayList;
delete pKeywordsList;
HashMap* pExtraInfoList = new HashMap;
delete pExtraInfoList;
r = Application::GetInstance()->GetAppFrame()->GetFrame()->AddControl(*__pAd);
return r;
But in runtime this generates error “[E_INVALID_ARG] Cannot add the target control to a frame.”


P.S. Sorry for my bad English


Hi, Where do you invoke CreateControl?


In GameField::init, GameField scene is created in AppDelegate::applicationDidFinishLaunching


OK, I will test this issue.:slight_smile:


Hi, I reviewed the code of ‘AdControl’, found that ad control is added to Form rather than Frame. So try the code as follow.



It works!
Thanks for help!


Not at all!:slight_smile: