Entity:
Filter:
GameLoop/Classes (extension) | Class

Entity
ExtensionExtension

The base class for entity creation in GameLoop

Description

Entity is the base class for all entity classes.

Class Methods

.new

Create a new entity

Arguments:

world

an instance of EntityManager

position

an instance of RealVector2D

radius

radius in meters

mass

a number/float

collisionType

a symbol for the collision type /free, /mobile or /static

Returns:

an Entity

Instance Methods

.position

.mass

.radius

.dt

.collisionType

.attach

Attach a representation to the entity.

NOTE: An entity is activated the moment a representation is attached. To have synchronous start of sound entities you need to add them before any visual reps. If a visual entity is attached before the sound representation the entity will synchronise with the delay needed for the visual which is usually zero.

.colliding

Returns true if the entity is colliding and false if it is not.

.detach

Dettach a representation.

.collisionFunc

Set the collision function. The function is passed in the current entity and an array containing the colliding entities.

.add

Add the entity to the manager. Usually we let this happen automatically the moment we attach the first representation. The entity is going to be added synchronously with the first attached representation.

.world

Get the EntityManager

.detachAll

Detach all representations.

.remove

Remove the entity. This will remove all the attached representations.

.active

Check if the entity is active aka. has been added to the manager.