-
Notifications
You must be signed in to change notification settings - Fork 4
Banner
Functions for creating and managing banner ads - a small ad that stays anchored to the top or bottom of the screen.
This module offers a collection of functions designed to address specific tasks and provide utilities for various purposes. Explore the available functions to make the most of the functionalities provided by this module.
- admob_banner_set_ad_unit
- admob_banner_create
- admob_banner_create_ext
- admob_banner_get_width
- admob_banner_get_height
- admob_banner_move
- admob_banner_show
- admob_banner_hide
- admob_banner_remove
This module includes a set of predefined constants that can be utilized for various purposes. Browse through the available constants to find values relevant to your needs and enhance the efficiency of your code.
Sets the ad unit ID used by admob_banner_create/admob_banner_create_ext. Must be called before either of those.
Syntax:
admob_banner_set_ad_unit(ad_unit_id)
| Argument | Type | Description |
|---|---|---|
| ad_unit_id | String | The banner ad unit ID, from the AdMob dashboard. |
Returns:
N/A
Creates and loads a banner ad, horizontally centered, anchored to the top or bottom of the screen. Only one banner exists at a time - calling this again replaces the previous banner.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
admob_banner_create(size, bottom, callback)
| Argument | Type | Description |
|---|---|---|
| size | AdMobBannerSize | The banner size to request. |
| bottom | Boolean |
true to anchor the banner to the bottom of the screen, false for the top. |
| callback | Function | The function to call for every lifecycle event on this banner, for as long as it exists. |
Returns:
AdMobError.Ok if the create request was accepted, an error code otherwise.
Triggers:
Fires once per lifecycle event, for as long as this banner exists (not a one-shot load-then-show pair like the other ad families - a banner has one ongoing callback for its whole lifecycle).
| Key | Type | Description |
|---|---|---|
| result | AdMobResult | The event's result. success is false only forAdMobBannerCallbackEvent.LoadFailed. |
| type | AdMobBannerCallbackEvent | Which lifecycle event this is. |
Example:
admob_banner_set_ad_unit("ca-app-pub-3940256099942544/6300978111");
admob_banner_create(AdMobBannerSize.Banner, true, function(_result, _type)
{
if (_type == AdMobBannerCallbackEvent.LoadFailed)
show_debug_message($"Banner failed to load: {_result.error_message}");
else
show_debug_message($"Banner event: {_type}");
});Same as admob_banner_create, with an explicit horizontal alignment instead of always centering.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Callback.
Syntax:
admob_banner_create_ext(size, bottom, alignment, callback)
| Argument | Type | Description |
|---|---|---|
| size | AdMobBannerSize | The banner size to request. |
| bottom | Boolean |
true to anchor the banner to the bottom of the screen, false for the top. |
| alignment | AdMobBannerAlignment | The horizontal alignment for the banner. |
| callback | Function | The function to call for every lifecycle event on this banner, for as long as it exists. |
Returns:
AdMobError.Ok if the create request was accepted, an error code otherwise.
Triggers:
Fires once per lifecycle event, for as long as this banner exists. Same shape as admob_banner_create's callback.
| Key | Type | Description |
|---|---|---|
| result | AdMobResult | The event's result. success is false only forAdMobBannerCallbackEvent.LoadFailed. |
| type | AdMobBannerCallbackEvent | Which lifecycle event this is. |
Gets the width, in pixels, of the current banner ad.
Syntax:
admob_banner_get_width()
Returns:
The banner's width in pixels, or 0 if no banner exists.
Gets the height, in pixels, of the current banner ad.
Syntax:
admob_banner_get_height()
Returns:
The banner's height in pixels, or 0 if no banner exists.
Moves the current banner ad to the opposite edge of the screen.
Syntax:
admob_banner_move(bottom)
| Argument | Type | Description |
|---|---|---|
| bottom | Boolean |
true to anchor the banner to the bottom of the screen, false for the top. |
Returns:
N/A
Makes a previously-hidden banner ad visible again. Does nothing if no banner exists.
Syntax:
admob_banner_show()
Returns:
N/A
Hides the current banner ad without destroying it - it keeps its loaded state and can be shown again with admob_banner_show. Does nothing if no banner exists.
Syntax:
admob_banner_hide()
Returns:
N/A
Destroys the current banner ad entirely. Call admob_banner_create/ admob_banner_create_ext again to create a new one.
Syntax:
admob_banner_remove()
Returns:
N/A
Extension-defined horizontal banner placement values, used by admob_banner_create_ext.
These constants are referenced by the following functions:
| Member | Description |
|---|---|
Left |
|
Center |
|
Right |
Extension-defined numeric mapping to Google's banner-size APIs.
These constants are referenced by the following functions:
| Member | Description |
|---|---|
Banner |
A standard 320x50 banner. |
LargeBanner |
A 320x100 banner. |
MediumRectangle |
A 300x250 banner. |
FullBanner |
A 468x60 banner. |
Leaderboard |
A 728x90 banner. |
SmartBanner |
A screen-width, auto-height banner. Deprecated by Google in favor of adaptive banners - kept for backward compatibility. |
AnchoredAdaptive |
A screen-width banner with a height Google optimizes for the current device and orientation. The recommended choice for new integrations. |
The lifecycle events admob_banner_create/admob_banner_create_ext's callback can fire with. Numeric values are extension-owned.
These constants are referenced by the following functions:
| Member | Description |
|---|---|
Loaded |
The banner finished loading and is ready to show. |
LoadFailed |
The banner failed to load. AdMobResult.success is false for thisevent only. |
Opened |
The banner was clicked and an overlay was presented. |
Clicked |
The user clicked the banner. |
Closed |
The overlay presented after a click was closed. |
Impression |
The banner recorded an impression. |
YoYoGames 2026