bool init(char* androidAppKey, char* iosAppKey, bool enableTesting, bool enableLogging, bool useEvents) { //todo? might want a reloadAdOnSurfaceChange callback that asks for a new ad if there //is a rotation or resize event... bool initialised = false; if (s3eDeviceGetInt(S3E_DEVICE_OS) == S3E_OS_ID_ANDROID) { if (!androidAppKey || !androidAppKey[0]) return false; initialised = s3eAmazonAdsInit(androidAppKey, enableTesting, enableLogging) == S3E_RESULT_SUCCESS; } else if (s3eDeviceGetInt(S3E_DEVICE_OS) == S3E_OS_ID_IPHONE) { if (!iosAppKey || !iosAppKey[0]) return false; initialised = s3eAmazonAdsInit(iosAppKey, enableTesting, enableLogging) == S3E_RESULT_SUCCESS; } if (initialised && useEvents) { s3eAmazonAdsRegister(S3E_AMAZONADS_CALLBACK_AD_LOADED, onAdLoad, NULL); s3eAmazonAdsRegister(S3E_AMAZONADS_CALLBACK_AD_ACTION, onAdAction, NULL); s3eAmazonAdsRegister(S3E_AMAZONADS_CALLBACK_AD_ERROR, onAdError, NULL); } return initialised; }
// 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; }