BannerAd
Banner ad component. The banner ad component is a native component with a higher z-index than regular components. The banner ad component is hidden by default; call BannerAd.show() to display it.
style.width / style.height define the maximum available area. The ad is centered horizontally and aligned to the top within that area, without stretching or cropping; style.left / style.top are the coordinates of its top-left corner. Sizes are in logical pixels (dp on Android, pt on iOS), so there is no need to multiply or divide by pixelRatio; container dimensions and the pixel ratio are available from sud.getContainerInfo. The actual display size is provided through the BannerAd.onResize() event.
Properties
Object style
Style of the banner ad component. style.width / style.height are the maximum available area set by the developer and stay unchanged while the ad is displayed; style.realWidth / style.realHeight are the read-only actual display size and are 0 until the first successful display.
| Property | Type | Description |
|---|---|---|
| left | number | X coordinate of the top-left corner of the maximum available container, in logical pixels |
| top | number | Y coordinate of the top-left corner of the maximum available container, in logical pixels |
| width | number | Maximum available width, must be greater than 0 |
| height | number | Maximum available height, must be greater than 0 |
| realWidth | number | Actual ad width in logical pixels, read-only; 0 until the first successful display |
| realHeight | number | Actual ad height in logical pixels, read-only; 0 until the first successful display |
- To react to a size change: read the
width/heightarguments directly inside theBannerAd.onResize()listener. - To query the actual size from other game logic: read
bannerAd.style.realWidth/bannerAd.style.realHeight; both are0until the first successful display.
Methods
- BannerAd.show() — Display the banner ad
- BannerAd.hide() — Hide the banner ad
- BannerAd.destroy() — Destroy the banner ad
- BannerAd.onResize(function listener) — Listen for the banner ad actual size change event
- BannerAd.offResize(function listener) — Remove the listener for the banner ad actual size change event
- BannerAd.onLoad(function listener) — Listen for the banner ad load success event
- BannerAd.offLoad(function listener) — Remove the listener for the banner ad load success event
- BannerAd.onError(function listener) — Listen for banner ad load or display failure events
- BannerAd.offError(function listener) — Remove the listener for banner ad load or display failure events
