cocos2dx iOS Advanced Usage - yanivav/Documentation GitHub Wiki

###Hiding your banner You can hide and show your banner in run time, using ``showBanner`` and ``hideBanner`` methods: ```objectivec startappiOS* startAppBridge = startappiOS().sharedInstance(); startAppBridge->hideBanner(); startAppBridge->showBanner(); startAppBridge->isVisible(); ```

Call releaseBanner when you want to remove the banner and add it to a new scene/view controller:

startAppBridge->releaseBanner();

Back to top

###Controlling the size of your banner The size of the banner is determined by the second parameter which can receive one of the following values
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);

Back to top

###Using a fixed origin for your banner If you choose to locate the banner in a fixed origin rather than the view's top or bottom, simply pass the required origin point (x,y) upon initialization as explain in the following example

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);

Back to top

###Using banner delegates You can get various callbacks from StartApp Ads, by implementing a callback method and pass it when loading the ad.
  1. Add the following line to your header file where you would like to catch callbacks:
static void STACallbacks(const char *eventName , const char *eventError);
  1. 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 
   	...
}
  1. 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

Back to top

##Customizing your Splash Screen You can customize the appearance of your splash screen using the ``STASplashPreferences`` object, as describes below. After setting your required preferences, pass it to the ``showSplashAd`` method when initializing the splash screen in your _AppDelegate_ class.

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;

Back to top

⚠️ **GitHub.com Fallback** ⚠️