Module entity

The logical encapsulation of a single game object within a Scene.

Entity is responsible for many of the behavioral hooks that define a game object.

Entity extends BoundObject

Properties

alpha The opacity of the Entity, between 0 and 1.
auto_control (bool) Whether the entity is being controlled by the system and should ignore user input.
body The Body that represents Entity in physics space.
center An {x, y} vector of the Entity's center in meters.
controller The Controller that is controlling Entity
force_keyframe (bool) Whether to force a recorder keyframe this frame.
scene (read only) The Scene that contains Entity
size An {x, y} vector of the Entity's size in meters.
sprite The Sprite linked with the Entity
z The z position of the entity.

Class Methods

Entity:new () Create a new Entity

Hooks

spawn (self) Called when the entity is first added to a Scene.
main (self) Called once every frame.
presolve (self) Called before the physics solve step.


Properties

Properties. Significant fields on an instance.
alpha
The opacity of the Entity, between 0 and 1.

Default 1

auto_control
(bool) Whether the entity is being controlled by the system and should ignore user input.
body
The Body that represents Entity in physics space.

Not necessary for static scenes.

center
An {x, y} vector of the Entity's center in meters.

If Entity has a body , this command forwards to body.pos.

controller
The Controller that is controlling Entity
force_keyframe
(bool) Whether to force a recorder keyframe this frame.
scene
(read only) The Scene that contains Entity
size
An {x, y} vector of the Entity's size in meters.

This can be set in static Scenes. Setting this in Physics scenes will have no effect.

sprite
The Sprite linked with the Entity
z
The z position of the entity. This only affects the order in which the entity appears in relation to other rendered objects. This can be between 0.0 (closest to the screen, in front) and -256.0 (farthest from the screen, in back).

Default -100.0

Class Methods

Class Methods. Must be called on Class, with a capital leading character. e.g. Class:method("foo")
Entity:new ()
Create a new Entity

Returns:

    Entity

Hooks

Hooks. Callbacks implemented in subclasses to customize behavior. Hooks are called on individual instances.
spawn (self)
Called when the entity is first added to a Scene.

The Scene may not be started.

Parameters:

  • self Entity The instance
main (self)
Called once every frame.

The Scene is guaranteed to be started.

If Entity is in a physics Scene, main is called after the engine's solve step.

Parameters:

  • self Entity The instance
presolve (self)
Called before the physics solve step.

The Scene is guaranteed to be started.

If Entity is not in a physics Scene, presolve is not called.

Parameters:

  • self Entity The instance
generated by LDoc 1.3.12