Collider

BGE. Collider

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

Constructor

new Collider(colliderName, argsopt) → {void}

Creates a new Collider

Parameters:
Name Type Attributes Default Description
colliderName string

the name this collider will be identified by

args object <optional>
{}

additional properties to be added to this collider

Properties:
Name Type Description
colliderType string

The type of this collider - should be defined in sub classes (eg. "circle", "rectangle")

name string

Name this collider will be identified by

enabled boolean

Does this collider trigger onCollision() ?

offset_x integer

Horizontal offset from the GameEntity it is attached to

offset_y integer

Vertical offset from the GameEntity it is attached to

memberFlags 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-void

collidableFlags 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-void

compositorObject invalid

Used internal to Game - should not be modified manually

tagsList dynamic

Colliders can be tagged with any number of tags so they can be easily identified (e.g. "enemy", "wall", etc.)

Source:

Methods

adjustCompositorObject(x, y) → {void}

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

Parameters:
Name Type Description
x float
y float
Source:

debugDraw(draw2d, entityX, entityY, coloropt) → {void}

Helper function to draw an outline around the collider

Parameters:
Name Type Attributes Default Description
draw2d object
entityX float
entityY float
color integer <optional>
&hFF0000FF
Source:

refreshColliderRegion() → {void}

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

Source:

setupCompositor(game, entityName, entityId, entityX, entityY) → {void}

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

Parameters:
Name Type Description
game object

the game this collider is used by

entityName string

name of the entity that owns this collider

entityId string

id of the entity that owns this collider

entityX float

entity's x position

entityY float

entity's y position

Source: