Legal Notice, Privacy Policy

Impressum, Datenschutzerklärung

Cerberus X Documentation

Class Admob

The admob class provides simple support for the Google Admob advertising system, which allows you to add advertising to your games. More...

Declarations

Methods
AdViewHeight : Int () Returns the height of the ad view, or 0 if the ad view is hidden.
AdViewWidth : Int () Returns the width of the ad view, or 0 if the ad view is hidden.
HideAdView : Void () Hides the ad view and disables ads
ShowAdView : Void ( style:Int=1, layout:Int=2 ) Shows the ad view and enables ads.
Functions
GetAdmob : Admob () Get the global Admob object.

Detailed Discussion

The admob class provides simple support for the Google Admob advertising system, which allows you to add advertising to your games.

To use Admob advertising in your game:

  1. Create an Admob account and add a new site/app for your game. You can create an Admob account at http://www.admob.com
    • Add the app config setting ADMOB_PUBLISHER_ID to your game. This must be set to your app's Admob 'Publisher ID'. See App config settings.
      • Add the app config setting ADMOB_ANDROID_ADS_APPID to your game. This must be set to your app's Admob 'App ID'. See App config settings.
        • Import the brl.admob module into your game and use the Admob class to enable and disable ads as required.
            Example
            Import brl.admob

            ' Next you have to add your app id, a must since Admob v20.2.0
            #ADMOB_ANDROID_ADS_APPID="ca-app-pub-3940256099942544~~3347511713"

            #ADMOB_PUBLISHER_ID="ca-app-pub-3940256099942544/6300978111" 'replace with id from your admob account for banners


            Class MyApp Extends App

            Field admob:Admob
            Field interstitialAdmob:AdmobInterstitial
            Field layout:=1
            Field state:=1

            Method OnCreate()
            admob=Admob.GetAdmob()
            admob.ShowAdView 1,layout
            interstitialAdmob=AdmobInterstitial.GetAdmobInterstitial("ca-app-pub-3940256099942544/1033173712")
            SetUpdateRate 60
            End

            Method OnUpdate()
            If MouseHit( 0 )
            If state = 3
            admob.HideAdView
            state+=1
            Else If state = 1
            layout+=1
            If layout=7 layout=1
            admob.ShowAdView 1,layout
            state+=1
            Else If state = 2
            admob.HideAdView
            interstitialAdmob.ShowAdViewInterstitial
            state+=1
            Endif
            If state>=4 state=1
            End
            End

            Method OnRender()
            Local en:="disabled"
            If state=2 en="enabled"
            Cls
            PushMatrix
            Scale 2,2
            DrawText "Click to toggle ads! ads are currently "+en+" ("+state+":"+layout+")",DeviceWidth/4,DeviceHeight/4,.5,.5
            PopMatrix
            End

            End

            Function Main()
            New MyApp
            End

            Methods Documentation

            Method AdViewHeight : Int ()

            Returns the height of the ad view, or 0 if the ad view is hidden.

            See also

            AdViewWidth

            Method AdViewWidth : Int ()

            Returns the width of the ad view, or 0 if the ad view is hidden.

            See also

            AdViewHeight

            Method HideAdView : Void ()

            Hides the ad view and disables ads

            See also

            ShowAdView

            Method ShowAdView : Void ( style:Int=1, layout:Int=2 )

            Shows the ad view and enables ads. The style and layout parameters should be one of the following:

            StyleMeaning
            1Standard banner
            2Smart banner portrait
            3Smart banner landscape
            LayoutMeaning
            1Top left
            2Top center
            3Top right
            4Bottom left
            5Bottom center
            6Bottom right
            See also

            HideAdView


            Functions Documentation

            Function GetAdmob : Admob ()

            Get the global Admob object.