Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PhysicsSystem2D

Hierarchy

  • any
    • PhysicsSystem2D

Index

Constructors

Private constructor

Properties

Private _accumulator

_accumulator: number = 0

Private _allowSleep

_allowSleep: boolean = true

Private _autoSimulation

_autoSimulation: boolean = true

Private _delayEvents

_delayEvents: DelayEvent[] = []

Private _enable

_enable: boolean = true

Private _fixedTimeStep

_fixedTimeStep: number = 1.0 / 60.0

Private Readonly _gravity

_gravity: Vec2 = new Vec2(0, -10 * PHYSICS_2D_PTM_RATIO)

Private _maxSubSteps

_maxSubSteps: number = 1

Private _steping

_steping: boolean = false

Readonly collisionMatrix

collisionMatrix: ICollisionMatrix = new CollisionMatrix() as unknown as ICollisionMatrix

获取碰撞矩阵。

Readonly physicsWorld

physicsWorld: IPhysicsWorld

获取物理世界的封装对象,通过它你可以访问到实际的底层对象。

positionIterations

positionIterations: number = 10

位置迭代更新数

velocityIterations

velocityIterations: number = 10

速度更新迭代数

Static Readonly ID

ID: "PHYSICS_2D" = "PHYSICS_2D"

获取此系统的ID。

Accessors

allowSleep

  • get allowSleep(): boolean
  • set allowSleep(v: boolean): void
  • Gets or sets whether the physical system allows automatic sleep, which defaults to true.

    zh

    获取或设置物理系统是否允许自动休眠,默认为 true。

    Returns boolean

  • Gets or sets whether the physical system allows automatic sleep, which defaults to true.

    zh

    获取或设置物理系统是否允许自动休眠,默认为 true。

    Parameters

    • v: boolean

    Returns void

autoSimulation

  • get autoSimulation(): boolean
  • set autoSimulation(value: boolean): void

debugDrawFlags

  • get debugDrawFlags(): number
  • set debugDrawFlags(v: number): void

enable

  • get enable(): boolean
  • set enable(value: boolean): void

fixedTimeStep

  • get fixedTimeStep(): number
  • set fixedTimeStep(value: number): void

gravity

  • get gravity(): Vec2
  • set gravity(gravity: Vec2): void

maxSubSteps

  • get maxSubSteps(): number
  • set maxSubSteps(value: number): void

stepping

  • get stepping(): boolean

Static PHYSICSBOX2D

  • get PHYSICSBOX2D(): boolean

Static PHYSICSBUILTIN

  • get PHYSICSBUILTIN(): boolean

Static PHYSICSNONE

  • get PHYSICSNONE(): boolean

Static instance

Methods

callAfterStep

  • callAfterStep(target: object, func: Function): void

postUpdate

  • postUpdate(deltaTime: number): void
  • 执行一次物理系统的模拟,目前将在每帧自动执行一次。

    Parameters

    • deltaTime: number

      与上一次执行相差的时间,目前为每帧消耗时间

    Returns void

raycast

  • 检测哪些碰撞体在给定射线的路径上,射线检测将忽略包含起始点的碰撞体。

    method

    rayCast

    Parameters

    • p1: IVec2Like

      start point of the raycast

    • p2: IVec2Like

      end point of the raycast

    • Default value type: ERaycast2DType = ERaycast2DType.Closest

      optional, default is RayCastType.Closest

    • Default value mask: number = 4294967295

      optional, default is 0xffffffff

    Returns keyof Readonly<RaycastResult2D>[]

resetAccumulator

  • resetAccumulator(time?: number): void

step

  • step(fixedTimeStep: number): void

testAABB

testPoint

Generated using TypeDoc