sud.getContainerInfo
Synchronously gets OP container dimensions and the device pixel ratio for reading logical dimensions during game layout. Takes no arguments and does not return a Promise.
Return Value
Object
| Property | Type | Description |
|---|---|---|
| containerWidth | number | Logical width, in dp on Android and pt on iOS |
| containerHeight | number | Logical height, in dp on Android and pt on iOS |
| pixelRatio | number | Device pixel ratio; returns 1 when a valid ratio is unavailable |
Usage Notes
containerWidth/containerHeightreturn the actual logical dimensions of the game container. Games are not always displayed in full screen (e.g., embedded or split-screen scenarios), so the container dimensions may be smaller than the screen dimensions. Therefore they are not interchangeable withscreenWidth/screenHeight/windowWidth/windowHeightreturned by sud.getWindowInfo; game layout and ad positioning should use container dimensions.pixelRatioreturns the device pixel ratio, which is consistent with the value returned by sud.getWindowInfo and can be used interchangeably.
Example Code
javascript
const { containerWidth, containerHeight, pixelRatio } = sud.getContainerInfo();
console.log('Container logical size', containerWidth, containerHeight);
console.log('Device pixel ratio', pixelRatio);Using Dimensions with Banner
Banner's style.left/top/width/height, style.realWidth/realHeight, and onResize dimensions all use logical pixels. Use them directly without multiplying or dividing by pixelRatio. Pass the area actually reserved for ads by the game when calling sud.createBannerAd.
