Created
March 17, 2018 00:27
-
-
Save rtroe/b23e6bb347320152d6311714b7da9c6e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Initialise a new AdMob Ad Overlay. This is a Cross platform method which will run on both Android and iOS. | |
/// </summary> | |
/// <param name="game">The host game to et the service container from</param> | |
/// <param name="location">The location to place the add on the screen</param> | |
public AdManager(Game Game, Vector2 location) | |
{ | |
this.Game = Game; | |
#if __ANDROID__ | |
//Interstitial Ads | |
mInterstitialAd = new InterstitialAd(Game.Activity); | |
// Get the Game View | |
GameView = (View)Game.Services.GetService(typeof(View)); | |
// Create the Ad Container | |
AdContainer = new LinearLayout(Game.Activity) | |
{ | |
Orientation = Orientation.Horizontal | |
}; | |
AdContainer.SetGravity(GravityFlags.CenterHorizontal | GravityFlags.Bottom); | |
AdContainer.SetBackgroundColor(Android.Graphics.Color.Transparent); // Need on some devices, not sure why | |
//AdContainer.AddView(RewardedVideoAd); | |
// A layout to hold the ad container and game view | |
var mainLayout = new FrameLayout(Game.Activity); | |
mainLayout.AddView(GameView); | |
mainLayout.AddView(AdContainer); | |
Game.Activity.SetContentView(mainLayout); | |
#elif __IOS__ | |
ViewController = Game.Services.GetService(typeof(UIViewController)) as UIViewController; | |
Location = new CGPoint(location.X, location.Y); | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment