Package-level declarations

Types

Link copied to clipboard
class Commands(world: World)

Queues changes to a World so they happen together at apply instead of right away.

Link copied to clipboard
abstract class ComponentType<T : Any>(val name: String)

Key under which components of type T are stored in a World. Declare one per component class, usually as its companion object, so the class name doubles as the key:

Link copied to clipboard
value class Entity

Identifies an entity in a World by a slot index and a generation that changes when the slot is reused, so a stale handle never aliases a new entity. How the two are packed is not part of the API.

Link copied to clipboard

Receiver of the block passed to Commands.spawn. Queues components and a parent for the entity being spawned; they attach when the Commands are applied.

Link copied to clipboard

Marks an entity whose sprite is drawn between its last two fixed steps instead of at its current Transform, so motion integrated in Phase.FIXED_UPDATE looks smooth at any frame rate.

Link copied to clipboard
class Lifetime(duration: Duration)

A component that destroys its entity once remaining has run out, such as a bullet that flies for two seconds or the carrier of a burst of particles.

Link copied to clipboard
class Transform(var x: Float = 0.0f, var y: Float = 0.0f, var rotation: Float = 0.0f, var scaleX: Float = 1.0f, var scaleY: Float = 1.0f)

Position, rotation and scale of an entity in world units. Rotation is in radians; a positive rotation turns the entity clockwise on screen, because y points down.

Link copied to clipboard
class Velocity(var dx: Float = 0.0f, var dy: Float = 0.0f)

A component that moves its entity's Transform by dx and dy world units per second, such as a bullet, a falling rock or a score popup that rises.

Link copied to clipboard
class World(initialCapacity: Int = 1024)

Holds entities and their components. Entities are cheap handles; components are plain objects stored per ComponentType in dense arrays, so iterating one component type touches contiguous memory and a two-type query costs one array lookup per entity.

Link copied to clipboard

Position, rotation and scale of an entity in world space, after its Transform is combined with the world transforms of its ancestors. Rotation is in radians; a positive rotation turns clockwise on screen, because y points down.

Functions

Link copied to clipboard
fun World.drawnPositionOf(entity: Entity, alpha: Float): Vec2

Returns the position, in world units, at which the renderer draws entity this frame, so that a camera or an effect can follow what the player sees.

Link copied to clipboard

Computes the WorldTransform of every entity that has a parent and a Transform.

Link copied to clipboard

Makes the next frame draw entity exactly at its current Transform, with no blend from where it was a step ago.