Skip to content

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.

PropertyTypeDescription
leftnumberX coordinate of the top-left corner of the maximum available container, in logical pixels
topnumberY coordinate of the top-left corner of the maximum available container, in logical pixels
widthnumberMaximum available width, must be greater than 0
heightnumberMaximum available height, must be greater than 0
realWidthnumberActual ad width in logical pixels, read-only; 0 until the first successful display
realHeightnumberActual ad height in logical pixels, read-only; 0 until the first successful display
  • To react to a size change: read the width / height arguments directly inside the BannerAd.onResize() listener.
  • To query the actual size from other game logic: read bannerAd.style.realWidth / bannerAd.style.realHeight; both are 0 until the first successful display.

Methods ​