object:getMassWorldCenter()

类型 函数
对象 Body
physics.*
返回值 数字
修订 版本 2024.3703
关键词 body, 质量, 世界, 中心
另请参阅 object:getMassLocalCenter()

概述

此函数返回 body 质心在内容坐标系中的 xy 分量。

语法

object:getMassWorldCenter()

示例

-- Create a rectangle
local myRect = display.newRect( 0, 0, 100, 100 )

-- Add a body to the rectangle
physics.addBody( myRect, "dynamic" )

-- Get mass world center values
local x, y = myRect:getMassWorldCenter()