Collider
Colliders are attached to GameEntities and when two colliders intersect, it triggers the onCollision() method in the GameEntity
Properties
colliderType(string) — The type of this collider - should be defined in sub classes (eg. "circle", "rectangle")name(string) — Name this collider will be identified byenabled(boolean) — Does this collider trigger onCollision() ?offset(BGE.Math.Vector) — Offset from the GameEntity it is attached tomemberFlags(integer) — Bitflag for collision detection: this collider is in this group - https://developer.roku.com/en-ca/docs/references/brightscript/interfaces/ifsprite.md#setmemberflagsflags-as-integer-as-voidcollidableFlags(integer) — Bitflag for collision detection: this collider will only collider with colliders in this group - https://developer.roku.com/en-ca/docs/references/brightscript/interfaces/ifsprite.md#setcollidableflagsflags-as-integer-as-voidcompositorObject(roSprite) — Used internal to Game - should not be modified manuallytagsList(dynamic) — Colliders can be tagged with any number of tags so they can be easily identified (e.g. "enemy", "wall", etc.)
Constructor
new Collider(
colliderName: string,
args?: roAssociativeArray,
): ColliderCreates a new Collider
Parameters
colliderName(string) — the name this collider will be identified byargs(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 bygameEngine(Game)entityName(string) — name of the entity that owns this colliderentityId(string) — id of the entity that owns this colliderentityPosition(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