跳到主要内容

Shape

描述:

  形状是固体二维几何对象,用于处理 love.physics.

type

类型: 函数。

描述:

  获取字符串形式的对象类型。

签名:

type: function(self: Shape): string

返回值:

返回类型描述
string字符串类型。

Of

类型: 函数。

描述:

  检查对象是否属于某种类型。如果对象的层次结构中具有指定名称的类型,则此函数将返回 true。

签名:

typeOf: function(self: Shape, type_name: string): boolean

参数:

参数名类型描述
type_namestring要检查的类型的名称。

返回值:

返回类型描述
boolean如果对象属于指定类型,则为 true,否则为 false。

release

类型: 函数。

描述:

  销毁对象的 Lua 引用。如果该对象未被任何其他 LÖVE 对象或线程引用,则该对象将被完全删除。 这个方法可以用来立即清理资源,而不需要等待Lua的垃圾收集器。

签名:

release: function(self: Shape): boolean

返回值:

返回类型描述
boolean如果对象已通过此调用释放,则为 true;如果先前已释放过该对象,则为 false。

getType

类型: 函数。

描述:

  获取表示形状的字符串。 此函数对于条件调试绘图很有用。

签名:

getType: function(self: Shape): string

返回值:

返回类型描述
string形状的类型。

getRadius

类型: 函数。

描述:

  获取形状圆角外皮的半径。

签名:

getRadius: function(self: Shape): number

返回值:

返回类型描述
number像素半径。

setRadius

类型: 函数。

描述:

  设置 CircleShape 的半径。

签名:

setRadius: function(self: Shape, radius: number)

getChildCount

类型: 函数。

描述:

  返回子形状数量。

签名:

getChildCount: function(self: Shape): integer

testPoint

类型: 函数。

描述:

  检查点是否位于变换后的形状内部。

签名:

testPoint: function(self: Shape, x: number, y: number, angle: number, point_x: number, point_y: number): boolean

rayCast

类型: 函数。

描述:

  对变换后的形状作射线检测;未命中时返回 nil。

签名:

rayCast: function(self: Shape, x1: number, y1: number, x2: number, y2: number, maximum_fraction: number, x: number, y: number, angle: number, child_index?: integer): number | nil, number | nil, number | nil

computeAABB

类型: 函数。

描述:

  计算变换后的轴对齐包围盒。

签名:

computeAABB: function(self: Shape, x: number, y: number, angle: number, child_index?: integer): number, number, number, number

computeMass

类型: 函数。

描述:

  按密度计算质心、质量和转动惯量。

签名:

computeMass: function(self: Shape, density: number): number, number, number, number