cocos2dx ios advanced usage - yanivav/Documentation GitHub Wiki
Call releaseBanner
when you want to remove the banner and add it to a new scene/view controller:
startAppBridge->releaseBanner();
Value | Size | Best fits for |
---|---|---|
STA_AutoAdSize |
Auto-size (recommended) | detects the width of the device's screen in its current orientation, and provides the optimal banner for this size |
STA_PortraitAdSize_320x50 |
320x50 | iPhone/iPod touch in portrait mode |
STA_LandscapeAdSize_480x50 |
480x50 | iPhone/iPod touch in landscape mode |
STA_PortraitAdSize_768x90 |
768x90 | iPad in portrait mode |
STA_LandscapeAdSize_1024x90 |
1024x90 | iPad in landscape mode |
For example:
startAppBridge->loadBanner(startappiOS::STAAdOrigin_Bottom,
startappiOS::STA_PortraitAdSize_320x50);
You can load a new size for an existing banner, by using the setSTABannerSize
method:
startAppBridge->setSTABannerSize(startappiOS::STA_PortraitAdSize_320x50);
Locating your banner 100 pixels above the view's bottom:
startAppBridge->setOrigin(0, self.view.frame.size.height - 100);
You can change the origin of an existing banner, by using the setSTABannerSize/setSTAAutoOrigin methods:
startAppBridge->setSTAAutoOrigin(startappiOS::STAAdOrigin_Top);
or
startAppBridge->setOrigin(0, 50);
- Add the following line to your header file where you would like to catch callbacks:
static void STACallbacks(const char *eventName , const char *eventError);
- Then, implement the STACallbacks callback function with all needed callbacks, in the relevant cpp file. For example:
void HelloWorld::STACallbacks(const char *eventName , const char *eventError)
{
if(0==strcmp(eventName, "didLoadAd")){
...
}
else if(0==strcmp(eventName, "didShowAd")){
...
}
else
...
}
- Pass STACallbacks when loading the ad:
For Splash:
startAppBridge->showSplashAd(STACallbacks);
For Interstitial:
startAppBridge->loadAd(STACallbacks);
For Banner:
startAppBridge->loadBanner(startappiOS::STAAdOrigin_Bottom,
startappiOS:: STA_AutoAdSize,
STACallbacks);
###Callbacks List
####Splash callbacks
didLoadSplashAd
failedLoadSplashAd
didShowSplashAd
failedShowSplashAd
didCloseSplashAd
didClickSplashAd
####Interstitial callbacks
didLoadAd
failedLoadAd
didShowAd
failedShowAd
didCloseAd
didClickAd
####Banner callbacks
didDisplayBannerAd
failedLoadBannerAd
didClickBannerAd
For example - using splash preferences to choose template mode:
startappiOS::STASplashPreferences *splashPreferences = new startappiOS::STASplashPreferences();
splashPreferences->splashMode = startappiOS::STASplashModeTemplate;
startAppBridge->showSplashAd(splashPreferences);
###Splash Preferences API The following API describes all customization options available for the splash screen.
####►Splash screen mode Decide whether to use user-defined or template mode.
Parameter: splashMode
Values:
STASplashModeUserDefined
STASplashModeTemplate
Usage:
splashPreferences->splashMode = startappiOS::STASplashModeTemplate;
####►Change splash image (for user-defined mode) Change the splash screen image, instead of using the default one.
Parameter: splashUserDefinedImageName
Usage:
splashPreferences->splashUserDefinedImageName = @"MyImage";
####►Choosing splash template (for template mode) Choose of of 6 pre-designed templates.
Parameter: splashTemplateTheme
Values:
STASplashTemplateThemeDeepBlue
STASplashTemplateThemeSky
STASplashTemplateThemeAshenSky
STASplashTemplateThemeBlaze
STASplashTemplateThemeGloomy
STASplashTemplateThemeOcean
Usage:
splashPreferences->splashTemplateTheme = startappiOS::STASplashTemplateThemeBlaze;
####►Changing template's icon and title (for template mode) The SDK uses your default application's name and icon. You can choose however to use your own assets.
Parameters:
splashTemplateIconImageName
splashTemplateAppName
Usage:
splashPreferences->splashTemplateIconImageName = "MyIcon";
splashPreferences->splashTemplateAppName = "MyAppName";
####►Enable/Disable loading indicator (for user-defined mode) Choose whether to display a loading indicator on the splash screen.
Parameter: isSplashLoadingIndicatorEnabled
Values:
YES
NO
Usage:
splashPreferences->isSplashLoadingIndicatorEnabled = true;
####►Choose loading indicator's type (for user-defined and template modes) Choose which loading indicator type to display: iOS default activity indicator or a "dots" loading indicator
Parameter: splashLoadingIndicatorType
Values:
STASplashLoadingIndicatorTypeIOS
STASplashLoadingIndicatorTypeDots
Usage:
splashPreferences->splashLoadingIndicatorType = startappiOS::STASplashLoadingIndicatorTypeDots;
####►Change loading indicator's position (for user-defined mode) The loading indicator is displayed by default on the center of the screen. You can choose however to set a custom position.
Parameter: splashLoadingIndicatorCenterPoint
Values:
CGPointMake(x, y)
Usage:
splashPreferences->splashLoadingIndicatorCenterPoint.x = 100;
splashPreferences->splashLoadingIndicatorCenterPoint.y = 100;
####►Force landscape orientation (for user-defined and template modes) The SDK display the splash screen using the orientation supported by the application and the device real orientation. You can choose however to force landscape orientation.
Parameter: isLandscape
Values:
YES
NO
Usage:
splashPreferences->isLandscape = true;