britzldefold-metrics
britzl/defold-metrics/metrics.fps
Calculate and display performance metrics in Defold games
- GitHub: britzl/defold-metrics — pinned to
1.2.1- Pick a release from britzl/defold-metrics 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 fps from "metrics.fps"
- Pick a release from britzl/defold-metrics releases and add its Source code (zip) URL (or a packaged
Functions
create(samples?: number, format?: string, position?: Vector3, color?: Vector4): Metrics
Parameters
samples?:numberformat?:stringposition?:Vector3color?: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.