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
    1. Pick a release from VowSoftware/starly releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as starly from "starly.starly"

Functions

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 if distance is 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 of vector3 positions, 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: number
  • screenY: number
  • visible?: boolean — Determines if the cursor must be visible to the camera. If true, then this function returns undefined when 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: Vector3
  • visible?: boolean — Determines if the cursor must be visible to the camera. If true, then this function returns undefined when 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

Variables

c_display_width: number

c_display_height: number

c_display_ratio: number

c_behavior_center: Hash

c_behavior_expand: Hash

c_behavior_mixed: Hash

c_behavior_stretch: Hash