On this page
VowSoftware/starly/starly.starly
Scene orchestration for Defold: data-driven game states, transitions, and lifecycle hooks.
- GitHub: VowSoftware/starly — pinned to
2fe3aed- Pick a release from VowSoftware/starly releases and add its Source code (zip) URL (or a packaged
.zipasset, if the library ships one) togame.projectunder[project]dependencies, then Fetch Libraries in the Defold editor. - Run
bunx @defold-typescript/cli resolveto materialize its types. - Import it under a namespace alias of your choice:
import * as starly from "starly.starly"
- Pick a release from VowSoftware/starly releases and add its Source code (zip) URL (or a packaged
Functions
create(id: Hash)destroy(id: Hash)activate(id: Hash): Matrix4shake(id: Hash, count: number, duration: number, radius: number, durationScalar?: number, radiusScalar?: number)cancel_shake(id: Hash)is_shaking(id: Hash): booleanget_offset(id: Hash, distance: Vector3, absolute: boolean): Vector3get_world_area(id: Hash): LuaMultiReturn<[ number, number, number, number ]>get_tight_world_area(id: Hash, positions: Vector3[]): LuaMultiReturn<[ Vector3, number, number, number, number, number ]>screen_to_world(id: Hash, screenX: number, screenY: number, visible?: boolean): Vector3 | undefinedworld_to_screen(id: Hash, worldPosition: Vector3, visible?: boolean): Vector3 | undefinedget_viewport(id: Hash): LuaMultiReturn<[ number, number, number, number ]>get_view(id: Hash): Matrix4get_projection(id: Hash): Matrix4
create(id: Hash)
Creates a camera. This function is called automatically in the game object's script component.
Parameters
id:Hash— Camera game object id.
destroy(id: Hash)
Destroys a camera. This function is called automatically in the game object's script component.
Parameters
id:Hash— Camera game object id.
activate(id: Hash): Matrix4
Activates a camera. This function should be called in the render script before any making any draw calls.
Parameters
id:Hash— Camera game object id.
Returns
Matrix4— frustum
shake(id: Hash, count: number, duration: number, radius: number, durationScalar?: number, radiusScalar?: number)
Shakes a camera.
Parameters
id:Hash— Camera game object id.count:number— Amount of pingpong movements.duration:number— Duration of each pingpong.radius:number— Distance of each pingpong.durationScalar?:number— After each pingpong, the duration is scaled by this value.radiusScalar?:number— After each pingpong, the radius is scaled by this value.
cancel_shake(id: Hash)
Cancels an ongoing camera shake.
Parameters
id:Hash— Camera game object id.
is_shaking(id: Hash): boolean
Checks if a camera is shaking.
Parameters
id:Hash— Camera game object id.
Returns
boolean
get_offset(id: Hash, distance: Vector3, absolute: boolean): Vector3
Gets the position offset of a camera after moving distance units, accounting for zoom and rotation.
Parameters
id:Hash— Camera game object id.distance:Vector3— Position offset, before accounting for zoom and rotation.absolute:boolean— Determines ifdistanceis in absolute world coordinates, which ignore rotation.
Returns
Vector3
get_world_area(id: Hash): LuaMultiReturn<[ number, number, number, number ]>
Gets the world area of a camera, which is defined as the rectangular area of the world that the camera can see, in world coordinates.
Parameters
id:Hash— Camera game object id.
Returns
LuaMultiReturn<[ number, number, number, number ]>— x, y, width, height
get_tight_world_area(id: Hash, positions: Vector3[]): LuaMultiReturn<[ Vector3, number, number, number, number, number ]>
Gets the center position, minimum zoom, and minimum world area of a camera that can see all positions.
This function was inspired by Super Smash Bros, where the camera moves and zooms to center and include all characters, with only a small amount of padding to the sides of the window.
Parameters
id:Hash— Camera game object id.positions:Vector3[]— Array ofvector3positions, in world coordinates.
Returns
LuaMultiReturn<[ Vector3, number, number, number, number, number ]>— position, zoom, x, y, width, height
screen_to_world(id: Hash, screenX: number, screenY: number, visible?: boolean): Vector3 | undefined
Converts screen coordinates to world coordinates.
Parameters
id:Hash— Camera game object id.screenX:numberscreenY:numbervisible?:boolean— Determines if the cursor must be visible to the camera. Iftrue, then this function returnsundefinedwhen the cursor is outside the camera's viewport.
Returns
Vector3 | undefined
world_to_screen(id: Hash, worldPosition: Vector3, visible?: boolean): Vector3 | undefined
Converts world coordinates to screen coordinates.
Parameters
id:Hash— Camera game object id.worldPosition:Vector3visible?:boolean— Determines if the cursor must be visible to the camera. Iftrue, then this function returnsundefinedwhen the cursor is outside the camera's viewport.
Returns
Vector3 | undefined
get_viewport(id: Hash): LuaMultiReturn<[ number, number, number, number ]>
Gets the viewport of a camera, in screen coordinates.
Parameters
id:Hash— Camera game object id.
Returns
LuaMultiReturn<[ number, number, number, number ]>— x, y, width, height
get_view(id: Hash): Matrix4
Gets the view of a camera.
Parameters
id:Hash— Camera game object id.
Returns
Matrix4
get_projection(id: Hash): Matrix4
Gets the projection of a camera.
Parameters
id:Hash— Camera game object id.
Returns
Matrix4