Hierarchy

  • Polygon
    • PolygonBody

Implements

Constructors

Properties

angle: number
bbox: BBox

bounding box cache, without padding

calcPoints: Vector[]
centered: boolean

is body centered

convexPolygons: Polygon[]

optimization for convex polygons

destroy$: Subject<void> = ...

When Lifecycle Object is destroyed, it emits and closes this subject. Along with destroying his children, which in turn behave the same.

dirty: boolean

was the polygon modified and needs update in the next checkCollision

edges: Vector[]
gameObject: GameObject

Parent GameObject is assigned at creation.

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

label: string = 'PolygonBody'

Each Lifecycle Object has label for pixi debugging.

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: Vector[]
offset: Vector
padding: number

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

points: Vector[]
pointsBackup: Vector[]

backup of points used for scaling

pos: Vector
scaleVector: Vector

scale Vector of body

system?: System<Body>

reference to collision system

type: Ellipse | Line | Box | Point | Polygon

type of body

update$: Subject<number> = ...

When Lifecycle Object is updated, it emits this subject. Along with updating his children, which in turn behave the same.

Accessors

  • get isCentered(): boolean
  • is polygon centered?

    Returns boolean

  • set isCentered(isCentered): void
  • flag to set is polygon centered

    Parameters

    • isCentered: boolean

    Returns void

  • get scale(): number
  • allow approx getting of scale

    Returns number

  • set scale(scale): void
  • allow easier setting of scale

    Parameters

    • scale: number

    Returns void

  • 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

  • get x(): number
  • Returns number

  • set x(x): void
  • updating this.pos.x by this.x = x updates AABB

    Parameters

    • x: number

    Returns void

  • get y(): number
  • Returns number

  • set y(y): void
  • updating this.pos.y by this.y = y updates AABB

    Parameters

    • y: number

    Returns void

Methods

  • Draws exact collider on canvas context

    Parameters

    • context: CanvasRenderingContext2D

    Returns void

  • Draws Bounding Box on canvas context

    Parameters

    • context: CanvasRenderingContext2D

    Returns void

  • Returns Polygon

  • get body bounding box, without padding

    Returns BBox

  • Returns Vector

  • get body centroid without applied angle

    Returns Vector

  • returns body split into convex polygons, or empty array for convex bodies

    Returns Polygon[]

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

    Returns boolean

  • update instantly or mark as dirty

    Parameters

    • Optional update: boolean

    Returns void

  • Parameters

    • Optional isCentered: boolean

    Returns void

  • rotates polygon points by angle, in radians

    Parameters

    • angle: number

    Returns Polygon

  • Parameters

    • angle: number
    • Optional update: boolean

    Returns Polygon

  • Parameters

    • offset: Vector
    • Optional update: boolean

    Returns Polygon

  • sets polygon points to new array of vectors

    Parameters

    • points: Vector[]

    Returns Polygon

  • update position

    Parameters

    • x: number
    • y: number
    • Optional update: boolean

    Returns Polygon

  • update scale

    Parameters

    • x: number
    • Optional y: number
    • Optional update: boolean

    Returns Polygon

  • translates polygon points in x, y direction

    Parameters

    • x: number
    • y: number

    Returns Polygon

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

    Parameters

    • Optional update: boolean

    Returns void

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

    Returns void

  • updates convex polygons cache in body

    Parameters

    • Optional convex: Polygon[]

    Returns void

  • after points update set is convex

    Returns void