跳到主要内容

renderer.getBounds()

以 Scratch 坐标获取可绘制对象的紧致包围盒。

语法

renderer.getBounds(drawableID)

参数

drawableID

类型: number

可绘制对象的 ID。

返回值

类型: object

一个包含以下属性的对象:

  • leftrighttopbottom(Scratch 坐标)
  • widthheight

示例

const bounds = renderer.getBounds(drawableId);
console.log(`Left: ${bounds.left}, Top: ${bounds.top}`);

另请参阅