Skip to main content

createGlobal

@zylem/game-lib


@zylem/game-lib / globals / createGlobal

Function: createGlobal()

createGlobal<T>(path, defaultValue): T

Defined in: packages/game-lib/src/lib/game/game-state.ts:43

Create/initialize a global with a default value. Only sets the value if it doesn't already exist. Use this to ensure globals have initial values before game starts.

Type Parameters​

T​

T

Parameters​

path​

string

defaultValue​

T

Returns​

T

Examples​

createGlobal('score', 0)
createGlobal('player.health', 100)