getMenuButtonBoundingClientRect
获取菜单按钮布局信息
getMenuButtonBoundingClientRect 是同步代理方法,用于向游戏提供右上角菜单按钮(胶囊按钮)的位置和尺寸。坐标原点为游戏 View 的左上角。
方法声明
objectivec
- (nonnull SUDOPMenuButtonBoundingClientRect *)getMenuButtonBoundingClientRect;参数说明
该方法无需传入参数。
返回值
此回调为可选方法。宿主实现时须返回一个非空的 SUDOPMenuButtonBoundingClientRect 对象。没有可用的胶囊区域时,返回各字段均为 0 的矩形对象。
| 属性 | 类型 | 描述 |
|---|---|---|
| width | NSInteger | 菜单按钮宽度。 |
| height | NSInteger | 菜单按钮高度。 |
| top | NSInteger | 菜单按钮上边缘的纵坐标。 |
| right | NSInteger | 菜单按钮右边缘的横坐标。 |
| bottom | NSInteger | 菜单按钮下边缘的纵坐标。 |
| left | NSInteger | 菜单按钮左边缘的横坐标。 |
App 侧填写的坐标和尺寸使用 iOS 逻辑点(pt);SDK 会在传递给游戏前转换为游戏使用的像素值。
布局完成后,用 [buttonView convertRect:buttonView.bounds toView:gameView] 取得胶囊在游戏 View 内的矩形,再用这个矩形的边界和宽高填写六个字段,单位为 pt。
代码示例
objectivec
- (SUDOPMenuButtonBoundingClientRect *)getMenuButtonBoundingClientRect {
SUDOPMenuButtonBoundingClientRect *rect =
[[SUDOPMenuButtonBoundingClientRect alloc] init];
rect.width = 87;
rect.height = 32;
rect.top = 48;
rect.right = 407;
rect.bottom = 80;
rect.left = 320;
return rect;
}注意事项
right和bottom分别表示右边缘的横坐标和下边缘的纵坐标。- 应保证
right = left + width、bottom = top + height。 - 屏幕旋转或菜单按钮位置变化后,下一次回调应返回最新布局。
