Skip to content
ClassTypes & Utilities@public

FlxG

Static compatibility facade delegating to one active link.

ts
export declare class FlxG

Properties

PropertyModifiersTypeDescription
actionsstatic readonlyFlxActions-
atlasstatic readonlyFlxAtlasRegistryThe atlas registry. Load named atlases then look them up by key:


ts<br>await FlxG.atlas.load('player', './player.png', './player.xml');<br>const atlas = FlxG.atlas.get('player');<br><br>
Safe to call before FlxGame boots — a shared fallback registry is used and then attached to the active context when one appears.
bgColorstaticnumber-
BLACKstatic readonly``-
BLUEstatic readonly``-
camerastaticFlxCamera-
camerasstatic readonlyreadonly FlxCamera[]-
contextstatic readonlyFlxContext-
DEBUGGER_BIGstatic readonly``-
DEBUGGER_LEFTstatic readonly``-
DEBUGGER_MICROstatic readonly``-
DEBUGGER_RIGHTstatic readonly``-
DEBUGGER_STANDARDstatic readonly``-
DEBUGGER_TOPstatic readonly``-
elapsedstaticnumber-
gamepadsstatic readonlyFlxGamepadManager-
globalSeedstaticnumber-
GREENstatic readonly``-
hasContextstatic readonlyboolean-
heightstatic readonlynumber-
keysstatic readonlyKeyboard-
levelstaticnumber-
levelsstatic readonlyunknown[]-
LIBRARY_MAJOR_VERSIONstatic readonly``-
LIBRARY_MINOR_VERSIONstatic readonly``-
LIBRARY_NAMEstatic readonly``-
logstatic readonlyFlxLogLive log accessible via FlxG.log.add('message'). Requires a FlxGame instance to be active (the log service is installed by FlxGame).
mousestatic readonlyMouse-
musicstatic readonlyFlxSound | nullThe currently playing music track, or null.
musicGroupstatic readonlyFlxSoundGroupDefault bus for music.
mutestaticbooleanGlobal mute flag.
pausedstaticboolean-
PINKstatic readonly``-
pluginsstatic readonlyreadonly FlxBasic[]-
REDstatic readonly``-
savestatic readonlyFlxSavePrimary save slot.
savesstatic readonlyFlxSave[]All registered save slots.
scorestaticnumber-
scoresstatic readonlyunknown[]-
soundGroupstatic readonlyFlxSoundGroupDefault bus for sound effects.
soundsstatic readonlyFlxGroupThe active sound-effects group.
statestatic readonlyFlxState | null-
timeScalestaticnumber-
touchesstatic readonlyFlxTouchManager-
vcrstatic readonlyFlxVCRGlobal VCR state object.
virtualInputsstatic readonlyFlxVirtualInputContext-owned registry resolved by serializable virtual action sources.
visualDebugstaticboolean-
volumestaticnumberGlobal volume (0–1).
watchstatic readonlyFlxWatchLive watch panel accessible via FlxG.watch.add(obj, 'field'). Requires a FlxGame instance to be active.
WHITEstatic readonly``-
widthstatic readonlynumber-
worldBoundsstaticFlxRect-
worldDivisionsstaticnumber-

Methods

static addCamera()

ts
static addCamera(camera: FlxCamera): FlxCamera

Parameters:

ParameterTypeDescription
cameraFlxCamera-

Returns: FlxCamera

static addPlugin()

ts
static addPlugin<T extends FlxBasic>(plugin: T): T

Parameters:

ParameterTypeDescription
pluginT-

Returns: T

static clearContext()

ts
static clearContext(context?: FlxContext): void

Parameters:

ParameterTypeDescription
contextFlxContext-

Returns: void

static collide()

ts
static collide(first?: FlxBasic | null, second?: FlxBasic | null, notify?: FlxOverlapCallback | null): boolean

Parameters:

ParameterTypeDescription
firstFlxBasic | null-
secondFlxBasic | null-
notifyFlxOverlapCallback | null-

Returns: boolean

static fade()

ts
static fade(color?: number, duration?: number, onComplete?: FlxCameraEffectCallback | null, force?: boolean): void

Parameters:

ParameterTypeDescription
colornumber-
durationnumber-
onCompleteFlxCameraEffectCallback | null-
forceboolean-

Returns: void

static flash()

ts
static flash(color?: number, duration?: number, onComplete?: FlxCameraEffectCallback | null, force?: boolean): void

Parameters:

ParameterTypeDescription
colornumber-
durationnumber-
onCompleteFlxCameraEffectCallback | null-
forceboolean-

Returns: void

static getLibraryName()

ts
static getLibraryName(): string

Returns: string

static getPlugin()

ts
static getPlugin<T extends FlxBasic>(pluginClass: FlxPluginConstructor<T>): T | null

Parameters:

ParameterTypeDescription
pluginClassFlxPluginConstructor<T>-

Returns: T | null

static getRandom()

ts
static getRandom<T>(objects: readonly T[] | null, startIndex?: number, length?: number): T | null

Parameters:

ParameterTypeDescription
objectsreadonly T[] | null-
startIndexnumber-
lengthnumber-

Returns: T | null

static installContext()

ts
static installContext(context: FlxContext): void

Parameters:

ParameterTypeDescription
contextFlxContext-

Returns: void

static loadReplay()

ts
static loadReplay(replay: FlxReplay, reloadState?: FlxState | null, cancelKeys?: string[], timeout?: number, onComplete?: (() => void) | null): void

Loads and starts playback of a recorded replay.

Parameters:

ParameterTypeDescription
replayFlxReplay-
reloadStateFlxState | null-
cancelKeysstring[]-
timeoutnumber-
onComplete(() => void) | null-

Returns: void

static overlap()

ts
static overlap(first?: FlxBasic | null, second?: FlxBasic | null, notify?: FlxOverlapCallback | null, process?: FlxProcessCallback | null): boolean

Parameters:

ParameterTypeDescription
firstFlxBasic | null-
secondFlxBasic | null-
notifyFlxOverlapCallback | null-
processFlxProcessCallback | null-

Returns: boolean

static pauseSounds()

ts
static pauseSounds(): void

Pause all sounds and music.

Returns: void

static play()

ts
static play(source: unknown, volume?: number, loop?: boolean, autoDestroy?: boolean, group?: FlxSoundGroup): FlxSound

Play a sound effect.

Parameters:

ParameterTypeDescription
sourceunknownAudioBuffer, URL string, or asset alias.
volumenumberPer-instance volume (0–1). Defaults to 1.
loopbooleanWhether to loop. Defaults to false.
autoDestroybooleanWhether to auto-destroy when done. Defaults to true.
groupFlxSoundGroup-

Returns: FlxSound

static playMusic()

ts
static playMusic(source: unknown, volume?: number, group?: FlxSoundGroup): void

Play music, stopping the current track.

Parameters:

ParameterTypeDescription
sourceunknownAudioBuffer, URL string, or asset alias.
volumenumberVolume (0–1). Defaults to 1.
groupFlxSoundGroup-

Returns: void

static random()

ts
static random(): number

Returns: number

static recordReplay()

ts
static recordReplay(standardMode?: boolean): void

Begins recording deterministic gameplay input to a new replay.

Parameters:

ParameterTypeDescription
standardModebooleanIf true (default), resets the active state to frame 0 for deterministic replay alignment.

Returns: void

static reloadReplay()

ts
static reloadReplay(resetState?: boolean): void

Reloads the active replay from the beginning.

Parameters:

ParameterTypeDescription
resetStateboolean-

Returns: void

static removeCamera()

ts
static removeCamera(camera: FlxCamera, destroy?: boolean): boolean

Parameters:

ParameterTypeDescription
cameraFlxCamera-
destroyboolean-

Returns: boolean

static removePlugin()

ts
static removePlugin<T extends FlxBasic>(plugin: T): T

Parameters:

ParameterTypeDescription
pluginT-

Returns: T

static removePluginType()

ts
static removePluginType<T extends FlxBasic>(pluginClass: FlxPluginConstructor<T>): boolean

Parameters:

ParameterTypeDescription
pluginClassFlxPluginConstructor<T>-

Returns: boolean

static resetCameras()

ts
static resetCameras(camera?: FlxCamera): FlxCamera

Parameters:

ParameterTypeDescription
cameraFlxCamera-

Returns: FlxCamera

static resetInput()

ts
static resetInput(): void

Returns: void

static resetState()

ts
static resetState(): void

Returns: void

static resumeSounds()

ts
static resumeSounds(): void

Resume all sounds and music.

Returns: void

static shake()

ts
static shake(intensity?: number, duration?: number, onComplete?: FlxCameraEffectCallback | null, force?: boolean, direction?: FlxCameraShakeDirection): void

Parameters:

ParameterTypeDescription
intensitynumber-
durationnumber-
onCompleteFlxCameraEffectCallback | null-
forceboolean-
directionFlxCameraShakeDirection-

Returns: void

static shuffle()

ts
static shuffle<T>(objects: T[], howManyTimes: number): T[]

Parameters:

ParameterTypeDescription
objectsT[]-
howManyTimesnumber-

Returns: T[]

static stopRecording()

ts
static stopRecording(): string

Stops recording the current replay and returns its serialized JSON payload.

Returns: string

static stopReplay()

ts
static stopReplay(): void

Stops playback of the currently running replay.

Returns: void

static stream()

ts
static stream(url: string, volume?: number, loop?: boolean, autoDestroy?: boolean, group?: FlxSoundGroup): FlxSound

Play a streaming sound from a URL.

Parameters:

ParameterTypeDescription
urlstringThe streaming URL.
volumenumberPer-instance volume (0–1). Defaults to 1.
loopbooleanWhether to loop. Defaults to false.
autoDestroybooleanWhether to auto-destroy when done. Defaults to true.
groupFlxSoundGroup-

Returns: FlxSound

static switchState()

ts
static switchState(state: FlxState): void

Parameters:

ParameterTypeDescription
stateFlxState-

Returns: void

Released under the MIT License.