Class Polygon<UserDataType>

collider - polygon

Type Parameters

  • UserDataType = any

Hierarchy (view full)

Implements

Constructors

Properties

_group: number

group for collision filtering

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

calcPoints: SATVector[]
centered: boolean = false

is body centered

convexPolygons: SATPolygon[]

optimization for convex polygons

dirty: boolean = false

was the polygon modified and needs update in the next checkCollision

edges: SATVector[]
isConvex: boolean

is it a convex polgyon as opposed to a hollow inside (concave) polygon

isStatic: boolean

static bodies don't move but they collide

isTrigger: boolean

trigger bodies move but are like ghosts

maxX: number

maximum x bound of body

maxY: number

maximum y bound of body

minX: number

minimum x bound of body

minY: number

minimum y bound of body

normals: SATVector[]
offset: SATVector

each body may have offset from center

padding: number

bodies are not reinserted during update if their bbox didnt move outside bbox + padding

points: SATVector[]
pointsBackup: Vector[]

backup of points used for scaling

scaleVector: Vector = ...

scale Vector of body

system?: System<Body>

reference to collision system

type:
    | Ellipse
    | Polygon
    | Box
    | Line
    | Point = BodyType.Polygon

type of body

typeGroup:
    | Ellipse
    | Polygon
    | Box
    | Line
    | Point = BodyGroup.Polygon

faster than type

userData?: any

allows the user to set any misc data for client use

Accessors

  • get 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

    Returns number

    canInteract for how groups are used

    0x7fffffff // member of all groups (can interact with everyting)
    
  • set group(group): void
  • 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

    Parameters

    • group: number

    Returns void

    canInteract for how groups are used

    0x7fffffff // member of all groups (can interact with everyting)
    
  • get scaleX(): number
  • allow exact getting of scale x - use setScale(x, y) to set

    Returns number

  • get scaleY(): number
  • allow exact getting of scale y - use setScale(x, y) to set

    Returns number

Methods

  • if true, polygon is not an invalid, self-crossing polygon

    Returns boolean

  • update instantly or mark as dirty

    Parameters

    • updateNow: boolean = false

    Returns void

  • inner function for after position change update aabb in system and convex inner polygons

    Parameters

    • updateNow: boolean = ...

    Returns void

  • update the position of the decomposed convex polygons (if any), called after the position of the body has changed

    Returns void