bool prepareAdLayout(int adId, char* position, char* size, int width, int height) { s3eAmazonAdsPosition e_pos = S3E_AMAZONADS_POSITION_TOP; if (position && position[0]) { if (strcmp(position, "bottom") == 0) e_pos = S3E_AMAZONADS_POSITION_BOTTOM; else if (strcmp(position, "top") != 0) IwAssert(AMAZON_ADS, (false, "prepareAdLayout value invalid, using default of 'top'")); } s3eAmazonAdsSize e_size = S3E_AMAZONADS_SIZE_AUTO; if (size && size[0]) { if (strcmp(size, "custom") == 0 ) e_size = S3E_AMAZONADS_SIZE_CUSTOM; } int w = 0; int h = 0; if (e_size == S3E_AMAZONADS_SIZE_CUSTOM) { if (width == 300 && height == 50) e_size = S3E_AMAZONADS_SIZE_300x50; if (width == 320 && height == 50) e_size = S3E_AMAZONADS_SIZE_320x50; if (width == 300 && height == 250) e_size = S3E_AMAZONADS_SIZE_300x250; if (width == 600 && height == 90) e_size = S3E_AMAZONADS_SIZE_600x90; if (width == 728 && height == 90) e_size = S3E_AMAZONADS_SIZE_728x90; if (width == 1024 && height == 50) e_size = S3E_AMAZONADS_SIZE_1024x50; else { w = width; h = height; } } return s3eAmazonAdsPrepareAdLayout(adId, e_pos, e_size, w, h) == S3E_RESULT_SUCCESS; }
// on "init" you need to initialize your instance bool GameLayer::init() { if (!CCLayer::init()) return false; // Create main loop this->schedule(schedule_selector(GameLayer::update)); // COCOS2D TIP // Create Cocos2D objects here if (s3eAmazonAdsAvailable()) { g_AdId = 0; g_InterstatialId = 0; g_requestNewInterstatial = false; // //Use this for testing. // s3eAmazonAdsInit("your id here", true, true); // //Use this for production. // //s3eAmazonAdsInit("your id here", false, false); //Add the callbacks. s3eAmazonAdsRegister(S3E_AMAZONADS_CALLBACK_AD_ERROR, onAdError, this); s3eAmazonAdsRegister(S3E_AMAZONADS_CALLBACK_AD_LOADED, onAdLoad, this); //Prepare the ads. s3eAmazonAdsPrepareAd(&g_AdId); s3eAmazonAdsPrepareAd(&g_InterstatialId); // //Use this for banner bottom // s3eAmazonAdsPrepareAdLayout(g_AdId, S3E_AMAZONADS_POSITION_BOTTOM, S3E_AMAZONADS_SIZE_AUTO); // //Use this for banner top // //s3eAmazonAdsPrepareAdLayout(adId, S3E_AMAZONADS_POSITION_TOP, S3E_AMAZONADS_SIZE_AUTO); //Load the ad. s3eAmazonAdsLoadAd(g_AdId); //Load the interstatial. s3eAmazonAdsLoadInterstitialAd(g_InterstatialId); //Banner ad change timer. s3eTimerSetTimer(30000, _adBanner, NULL); } // Create Box2D world world = new b2World(b2Vec2(0, 100)); // BOX2D TIP // Create Box2D objects here return true; }