Skip to Content
defold-typescript libraries
britzldefold-metrics

britzl/defold-metrics/metrics.fps

Calculate and display performance metrics in Defold games

  • GitHub: britzl/defold-metrics — pinned to 1.2.1
    1. Pick a release from britzl/defold-metrics 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 fps from "metrics.fps"

Functions

create(samples?: number, format?: string, position?: Vector3, color?: Vector4): Metrics

Parameters

  • samples?: number
  • format?: string
  • position?: Vector3
  • color?: Vector4

Returns

  • Metrics

update()

Call this once per frame. Once enough samples have been collected it is possible to call fps() to get the current FPS.

fps(): number

Get the current FPS, based on collected samples.

Returns

  • number

draw()

Draw fps count text using draw_debug_text.

Variables

POSITION: Vector3

Where draw() places the text, and the default create() uses when given no position.

FORMAT: string

The string.format pattern the FPS reading is rendered through.

COLOR: Vector4

The colour draw() renders the text in, and the default create() uses when given no colour.

Types

Metrics

Metrics.fps: () => number

Metrics.update: () => void

Metrics.draw: () => void

On this page