2D edge collider.

2D边缘碰撞体。

层级 (查看完整内容)

构造函数

属性

Extra data of the node.

组件的额外数据。IDE内部使用。

_id: number

Unique identifier for the component.

组件的唯一标识。

_singleton: boolean

Whether the component is a singleton, meaning only one instance of this type of script can be added to the same node.

是否为单例,即同一个节点只能添加此类型的脚本一次。

label: string = "StaticCollider"

[Read-only] Custom label.

[只读] 自定义标签。

owner: Sprite

Gets the owner Node to which the component belongs.

获取组件所属的 Node 节点。

runInEditor: boolean

Whether the script can run in the IDE environment.

是否可以在 IDE 环境中运行。

scriptPath: string

The path of the script file.

脚本文件的路径。

访问器

  • get density(): number
  • 返回 number

    This is only for compatibility, and subsequent versions will set the density value in shape.

    The density value. The value can be zero or a positive number. It is recommended to use similar densities to improve stacking stability. The default value is 10.

    这个只做兼容,后续版本在shape中设置密度值大小.

    密度值。值可以为零或者是正数,建议使用相似的密度以改善堆叠稳定性。默认值为 10。

  • set density(value): void
  • 参数

    • value: number

    返回 void

  • get friction(): number
  • 返回 number

    This is only for compatibility, and subsequent versions will set friction in the shape.

    The friction coefficient. The value ranges from 0 to 1, the larger the value, the greater the friction. The default value is 0.2.

    这个只做兼容,后续版本在shape中设置摩擦力.

    摩擦力。取值范围0-1,值越大,摩擦越大。默认值为0.2。

  • set friction(value): void
  • 参数

    • value: number

    返回 void

  • get isSensor(): boolean
  • 返回 boolean

    This is only for compatibility. In subsequent versions, you can set whether the shape is a sensor.

    Whether the object is a sensor. A sensor can trigger collision events but does not produce collision responses.

    这个只做兼容,后续版本在shape中设置是否为传感器

    是否是传感器,传感器能够触发碰撞事件,但不会产生碰撞反应

  • set isSensor(value): void
  • 参数

    • value: boolean

    返回 void

方法

  • 返回 void

    Called after the component is added to a node. Unlike Awake, onAdded is called even if the node is not active.

    组件被添加到节点后调用,与 onAwake 不同的是,即使节点未激活也会调用 onAdded。

  • 返回 void

    Executed after the component is activated. At this point, all nodes and components have been created. This method is executed only once.

    组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次。

  • 返回 void

    Resets the component's parameters to their default values. If this function is implemented, the component will be reset and automatically recycled for future use. If not reset, it will not be recycled for reuse.

    将组件的参数重置为默认值。如果实现了这个函数,组件将被重置并自动回收到对象池,方便下次复用。 如果没有重置,则不会进行回收复用。

  • 返回 void

    Executed every frame during the update phase. Avoid writing complex loop logic or using the getComponent method here.

    每帧更新时执行,在 update 阶段。尽量不要在这里写大循环逻辑或使用 getComponent 方法。