Interface BodyProps<UserDataType>

each body contains those regardless of type

interface BodyProps<UserDataType> {
    angle?: number;
    bbox: BBox;
    dirty: boolean;
    group?: number;
    isCentered?: boolean;
    isConvex: boolean;
    isStatic?: boolean;
    isTrigger?: boolean;
    offset: SATVector;
    padding?: number;
    system?: System<Body>;
    type: BodyType;
    typeGroup: BodyGroup;
    userData?: UserDataType;
    get scaleX(): number;
    get scaleY(): number;
    draw(context: CanvasRenderingContext2D): void;
    drawBVH(context: CanvasRenderingContext2D): void;
    getAABBAsBBox(): BBox;
    move(speed: number, updateNow?: boolean): SATPolygon | Circle<any>;
    setAngle(angle: number, updateNow?: boolean): SATPolygon | Circle<any>;
    setOffset(offset: Vector, updateNow?: boolean): SATPolygon | Circle<any>;
    setPosition(x: number, y: number, updateNow?: boolean): SATPolygon | Circle<any>;
    setScale(x: number, y: number, updateNow?: boolean): SATPolygon | Circle<any>;
}

Type Parameters

  • UserDataType = any

Hierarchy (view full)

Implemented by

Properties

angle?: number

body angle in radians use deg2rad to convert move(speed) moves at 1 speed = 1px towards angle

bbox: BBox

bounding box cache, without padding

dirty: boolean

was the body modified and needs update in the next checkCollision

group?: number

group for collision filtering

Based on Box2D (tutorial)

Values in BodyGroup are predefined and used each the body type and should not be used for custom filtering

0b00000001 << 16 to 0b01000000 << 16 (max 0x7fffffff) are free to use for custom groups

canInteract for how groups are used

0x7fffffff // member of all groups (can interact with everyting)
isCentered?: boolean

is body offset centered for rotation purpouses

isConvex: boolean

flag to show is it a convex body or non convex polygon

isStatic?: boolean

system.separate() doesn't move this body

isTrigger?: boolean

system.separate() doesn't trigger collision of this body

offset: SATVector

each body may have offset from center

padding?: number

BHV padding for bounding box, preventing costly updates

system?: System<Body>

collisions system reference

type: BodyType

type of body

typeGroup: BodyGroup

faster for comparision, inner, type of body as number

userData?: UserDataType

allows the user to set any misc data for client use

Accessors

  • get scaleY(): number
  • scale getter (y = x for Circle)

    Returns number

Methods

  • draw the collider

    Parameters

    • context: CanvasRenderingContext2D

    Returns void

  • draw the bounding box

    Parameters

    • context: CanvasRenderingContext2D

    Returns void