Body |

Index

Constructors

constructor

Properties

ancestor

bounce

bounce: number

bounds

collisionType

collisionType: number

Readonlyfalling

falling: boolean

force

friction

gravityScale

gravityScale: number

ignoreGravity

ignoreGravity: boolean

ReadonlyisStatic

isStatic: boolean

Readonlyjumping

jumping: boolean

mass

mass: number

maxVel

onBodyUpdate

onBodyUpdate: Function | undefined

vel

Methods

addShape

  • Returns number

    the shape array length

addVertices

  • addVertices(vertices: Vector2d[], index?: number): void

    Parameters

    • vertices: Vector2d[]
    • Optionalindex: number = 0

    Returns void

contains

  • contains(...args: any[]): boolean

    Returns boolean

    true if contains

forEach

  • forEach(callback: Function, thisArg?: object): void

    Parameters

    • callback: Function
    • OptionalthisArg: object

    Returns void

fromJSON

  • fromJSON(json: object, id?: string): number

    Parameters

    • json: object
    • Optionalid: string

    Returns number

    how many shapes were added to the body

getBounds

  • Returns Bounds

    bounding box Rectangle object

getShape

  • Parameters

    • Optionalindex: number

    Returns Polygon | Ellipse | Line

    shape a shape object if defined

removeShape

  • Returns number

    the shape array length

removeShapeAt

  • removeShapeAt(index: number): number

    Returns number

    the shape array length

respondToCollision

  • Returns void

rotate

  • Parameters

    Returns Body

    Reference to this object for method chaining

setCollisionMask

  • setCollisionMask(bitmask?: number): void

    Parameters

    • Optionalbitmask: number = collision.types.ALL_OBJECT

    Returns void

setCollisionType

  • setCollisionType(type: number): void

    Returns void

setFriction

  • setFriction(x?: number, y?: number): void

    Parameters

    • x: number = 0
    • y: number = 0

    Returns void

setMaxVelocity

  • setMaxVelocity(x: number, y: number): void

    Parameters

    • x: number
    • y: number

    Returns void

setStatic

  • setStatic(isStatic?: boolean): void

    Parameters

    • OptionalisStatic: boolean = true

    Returns void

setVertices

  • setVertices(vertices: Vector2d[], index?: number, clear?: boolean): void

    Parameters

    • vertices: Vector2d[]
    • Optionalindex: number = 0
    • Optionalclear: boolean = true

    Returns void

Protectedupdate

  • Protected

    Returns boolean

    true if resulting velocity is different than 0