Collider

Colliders are attached to GameEntities and when two colliders intersect, it triggers the onCollision() method in the GameEntity

Properties


Constructor

new Collider( colliderName: string, args?: roAssociativeArray, ): Collider

Creates a new Collider

Parameters

  • colliderName (string) — the name this collider will be identified by
  • args (roAssociativeArray, optional, default: "{}") — additional properties to be added to this collider

Instance Methods

setupCompositor( game, gameEngine: Game, entityName: string, entityId: string, entityPosition: BGE.Math.Vector, ): void

Sets up this collider to be associated with a given game and entity

Parameters

  • game — the game this collider is used by
  • gameEngine (Game)
  • entityName (string) — name of the entity that owns this collider
  • entityId (string) — id of the entity that owns this collider
  • entityPosition (BGE.Math.Vector) — entity's position

Returns

  • void

refreshColliderRegion(): void

Refreshes the collider. Called every frame by the GameEngine. Should be overridden by sub classes if they have specialized collision set ups (e.g. circle, rectangle).

Returns

  • void

adjustCompositorObject(entityPosition: BGE.Math.Vector): void

Moves the compositor to the new x,y position - called from Game when the entity it is attached to moves

Parameters

  • entityPosition (BGE.Math.Vector)

Returns

  • void

debugDraw( renderObj: BGE.Renderer, position: BGE.Math.Vector, color?: integer, addName?: boolean, font?: roFont, ): void

Helper function to draw an outline around the collider

Parameters

  • renderObj (BGE.Renderer)
  • position (BGE.Math.Vector)
  • color (integer, optional, default: "&hFF0000FF")
  • addName (boolean, optional, default: false)
  • font (roFont, optional, default: "invalid")

Returns

  • void