Class TAds
Unit
Declaration
type TAds = class(TComponent)
Description
Advertisements in game. Right now only on Android (does nothing on other platforms, as CastleMessaging does nothing on non-Android platforms).
Usage:
Create an instance of this class (only a single instance allowed).
Initialize at least one ad network using one of the
InitializeXxx
methods. Usually you want to call the initialization from TCastleApplication.OnInitialize.Use remaining methods of this class to show / hide ads, like ShowFullScreenAd, ShowBanner, HideBanner.
To include the necessary integration code in your Android project, declare your Android project type as "integrated" with the appropriate services (admob, chartboost, startapp...) inside CastleEngineManifest.xml . See https://castle-engine.io/android-Project-Services-Integrated-with-Castle-Game-Engine .
Hierarchy
- TObject
- TPersistent
- TComponent
- TAds
Overview
Methods
procedure FullScreenAdClosed(const WatchedStatus: TAdWatchStatus); virtual; |
|
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
procedure InitializeAdMob(const BannerUnitId, InterstitialUnitId, RewardedUnitId: string; const TestDeviceIds: array of string); overload; |
|
procedure InitializeAdMob(const BannerUnitId, InterstitialUnitId: string; const TestDeviceIds: array of string); overload; |
|
procedure InitializeStartapp(const AppId: string); |
|
procedure InitializeChartboost(const AppId, AppSignature: string); |
|
procedure ShowFullScreenAd(const AdNetwork: TAdNetwork; const AdType: TFullScreenAdType; const WaitUntilLoaded: boolean); |
|
procedure ShowBanner(const AdNetwork: TAdNetwork; const HorizontalGravity: THorizontalPosition; const VerticalGravity: TVerticalPosition); |
|
procedure HideBanner(const AdNetwork: TAdNetwork); |
Properties
property OnFullScreenAdClosed: TAdClosedEvent
read FOnFullScreenAdClosed write FOnFullScreenAdClosed; |
|
property BannerSize: TRectangle read FBannerSize; |
Description
Methods
procedure FullScreenAdClosed(const WatchedStatus: TAdWatchStatus); virtual; |
|
This item has no description. |
constructor Create(AOwner: TComponent); override; |
|
This item has no description. |
destructor Destroy; override; |
|
This item has no description. |
procedure InitializeAdMob(const BannerUnitId, InterstitialUnitId, RewardedUnitId: string; const TestDeviceIds: array of string); overload; |
|
Initialize AdMob ads. You need to create the unit ids on AdMob website (or use TestAdMobBannerUnitId, TestAdMobInterstitialUnitId for testing). TestDeviceIds may be empty, or it may contain a list of devices where you always want to see test ads — even with real (non-test) ad units. This is useful when you test ads in your application (with real ad units, on a real phone). Paste here the list of your devices (see https://developers.google.com/mobile-ads-sdk/docs/admob/android/quick-start , you can see your device ids in "adb logcat" output) in order to avoid getting banned for clicking on your own ads. Usually called from TCastleApplication.OnInitialize. |
procedure InitializeAdMob(const BannerUnitId, InterstitialUnitId: string; const TestDeviceIds: array of string); overload; |
|
This item has no description. |
procedure InitializeStartapp(const AppId: string); |
|
Initialize StartApp ads. You need to register your game on http://startapp.com/ to get app id. Usually called from TCastleApplication.OnInitialize. |
procedure InitializeChartboost(const AppId, AppSignature: string); |
|
Initialize Chartboost ads. You need to register your game on http://chartboost.com/ to get app id and signature. Usually called from TCastleApplication.OnInitialize. |
procedure ShowFullScreenAd(const AdNetwork: TAdNetwork; const AdType: TFullScreenAdType; const WaitUntilLoaded: boolean); |
|
Show full-screen ad, interstitial (in-between) or reward ad. Not all ad networks support (or differentiate between) all full-screen ad types possible in TFullScreenAdType enumeration. So we eventually show other sensible ad type instead. If WaitUntilLoaded, then we wait until the ad contents are fetched (be sure to show some "loading" state to user, as it may take a while in case of a slow network). If not WaitUntilLoaded, then we immediately resign if ad is not loaded yet. Not all ad implementations support this setting reliably, so this is only a suggestion. In any case, after this method is called, we make sure to call callback OnFullScreenAdClosed sometime. |
procedure ShowBanner(const AdNetwork: TAdNetwork; const HorizontalGravity: THorizontalPosition; const VerticalGravity: TVerticalPosition); |
|
Show banner ad. Banners are not supported by all ad networks (only AdMob now), in case they are unsupported this call is silently ignored. |
procedure HideBanner(const AdNetwork: TAdNetwork); |
|
Hide banner ad. Banners are not supported by all ad networks (only AdMob now), in case they are unsupported this call is silently ignored. |
Properties
property OnFullScreenAdClosed: TAdClosedEvent
read FOnFullScreenAdClosed write FOnFullScreenAdClosed; |
|
This item has no description. |
property BannerSize: TRectangle read FBannerSize; |
|
This item has no description. |
Generated by PasDoc 0.16.0-snapshot.