BodyComp:

The body component.

vel: Vec2

Object current velocity.

since

drag: number

How much velocity decays (velocity *= (1 - drag) every frame).

since

isStatic: boolean

If object is static, won't move, and all non static objects won't move past it.

jumpForce: number

Initial speed in pixels per second for jump().

mass: number

Mass of the body, decides how much a non-static body should move when resolves with another non-static body. (default 1).

since

stickToPlatform?: boolean

If object should move with moving platform (default true).

since

curPlatform(): GameObj | null

Current platform landing on.

isGrounded(): boolean

If currently landing on a platform.

since

isFalling(): boolean

If currently falling.

since

isJumping(): boolean

If currently rising.

since

addForce(force: Vec2): void

Applies a force

param

jump(force?: number): void

Upward thrust.

onPhysicsResolve(action: (col: Collision)=>void): KEventController

Register an event that runs when a collision is resolved.

since

onBeforePhysicsResolve(action: (col: Collision)=>void): KEventController

Register an event that runs before a collision would be resolved.

since

onGround(action: ()=>void): KEventController

Register an event that runs when the object is grounded.

since

onFall(action: ()=>void): KEventController

Register an event that runs when the object starts falling.

since

onFallOff(action: ()=>void): KEventController

Register an event that runs when the object falls off platform.

since

onHeadbutt(action: ()=>void): KEventController

Register an event that runs when the object bumps into something on the head.

since

onLand(action: (obj: GameObj)=>void): KEventController

Register an event that runs when an object lands on this object.

since

onHeadbutted(action: (obj: GameObj)=>void): KEventController

Register an event that runs when the object is bumped by another object head.
kaplay logo

Misc