Global helper class for audio, input, the camera system, the debugger and other global properties.

Static variables

staticread onlyVERSION:FlxVersion = new FlxVersion(4, 3, 0)

The HaxeFlixel version, in semantic versioning syntax. Use Std.string() on it to get a String formatted like this: "HaxeFlixel MAJOR.MINOR.PATCH-COMMIT_SHA".

staticautoPause:Bool = true

Whether the game should be paused when focus is lost or not. Use -D FLX_NO_FOCUS_LOST_SCREEN if you only want to get rid of the default pause screen. Override onFocus() and onFocusLost() for your own behaviour in your state.

staticread onlybitmap:BitmapFrontEnd = new BitmapFrontEnd()

Contains things related to bitmaps, for example regarding the BitmapData cache and the cache itself.

staticread onlybitmapLog:BitmapLogFrontEnd = new BitmapLogFrontEnd()

Used to add images to the bitmap log window.

staticcamera:FlxCamera

By default this just refers to the first entry in the FlxG.cameras.list array but you can do what you like with it.

staticread onlycameras:CameraFrontEnd = new CameraFrontEnd()

Contains things related to cameras, a list of all cameras and several effects like flash() or fade().

staticread onlyconsole:ConsoleFrontEnd = new ConsoleFrontEnd()

Used to register functions and objects or add new commands to the console window.

staticread onlydebugger:DebuggerFrontEnd = new DebuggerFrontEnd()

Used it to show / hide the debugger, change its layout, activate debug drawing or change the key used to toggle it.

staticdrawFramerate:Int

How many times you want your game to step each second. More steps usually means greater responsiveness, but it can also slowdown your game if the stage can't keep up with the update routine. NOTE: This is NOT the same thing as the update framerate!

staticread onlyelapsed:Float = 0

Represents the amount of time in seconds that passed since last frame.

staticfixedTimestep:Bool = true

WARNING: Changing this can lead to issues with physics and the recording system. Setting this to false might lead to smoother animations (even at lower fps) at the cost of physics accuracy.

staticfullscreen:Bool

Use this to toggle between fullscreen and normal mode. Works on CPP, Neko and Flash. You can easily toggle fullscreen with e.g.: FlxG.fullscreen = !FlxG.fullscreen;

staticread onlygame:FlxGame

Internal tracker for game object.

staticread onlygamepads:FlxGamepadManager

Allows accessing the available gamepads.

staticread onlyheight:Int

The height of the screen in game pixels. Read-only, use resizeGame() to change.

staticread onlyinitialHeight:Int = 0

staticread onlyinitialWidth:Int = 0

staticread onlyinitialZoom:Float = 0

staticread onlyinputs:InputFrontEnd = new InputFrontEnd()

Mostly used internally, but you can use it too to reset inputs and create input classes of your own.

staticread onlykeys:FlxKeyboard

Used for keyboard input e.g.: check if the left arrow key is pressed with if (FlxG.keys.pressed.LEFT) { } in update().

staticread onlylog:LogFrontEnd = new LogFrontEnd()

Used to add messages to the log window or enable trace() redirection.

staticmaxElapsed:Float = 0.1

Useful when the timestep is NOT fixed (i.e. variable), to prevent jerky movement or erratic behavior at very low fps. Essentially locks the framerate to a minimum value - any slower and you'll get slowdown instead of frameskip; default is 1/10th of a second.

staticmouse:FlxMouse

Used for mouse input. e.g.: check if the left mouse button is pressed with if (FlxG.mouse.pressed) { }) in update().

staticread onlyonMobile:Bool

Whether the game is running on a mobile device. If on HTML5, it returns FlxG.html5.onMobile. Otherwise, it checks whether the mobile haxedef is defined.

Available since

4.2.0

.

staticread onlyplugins:PluginFrontEnd

Contains a list of all plugins and the functions required to add(), remove() them etc.

staticread onlyrandom:FlxRandom = new FlxRandom()

A FlxRandom object which can be used to generate random numbers. Also used by Flixel internally.

staticread onlyrenderBlit:Bool

staticread onlyrenderTile:Bool

staticread onlysave:FlxSave = new FlxSave()

A FlxSave used internally by flixel to save sound preferences and the history of the console window, but no reason you can't use it for your own stuff too!

staticscaleMode:BaseScaleMode = new RatioScaleMode()

The scale mode the game should use - available policies are found in flixel.system.scaleModes.

staticread onlysignals:SignalFrontEnd = new SignalFrontEnd()

Contains system-wide signals like gameResized or stateSwitched.

staticread onlysound:SoundFrontEnd

Contains a list of all sounds and other things to manage or play() sounds.

staticread onlystage:Stage

The Flash stage object (required for event listeners). Will be null if it's not safe/useful yet.

staticread onlystate:FlxState

Access the current game state from anywhere. Consider using addChildBelowMouse() if you want to add a DisplayObject to the stage instead of directly adding it here!

staticread onlyswipes:Array<FlxSwipe> = []

Contains all "swipes" from both mouse and touch input that have just ended.

statictimeScale:Float = 1

How fast or slow time should pass in the game; default is 1.0.

staticread onlytouches:FlxTouchManager

Useful for devices with multitouch support.

staticupdateFramerate:Int

How many times you want your game to update each second. More updates usually means better collisions and smoother motion. NOTE: This is NOT the same thing as the draw framerate!

staticread onlyvcr:VCRFrontEnd

Contains all the functions needed for recording and replaying.

staticread onlywatch:WatchFrontEnd = new WatchFrontEnd()

Used to add or remove things to / from the watch window.

staticread onlywidth:Int

The width of the screen in game pixels. Read-only, use resizeGame() to change.

staticread onlyworldBounds:FlxRect = FlxRect.get()

The dimensions of the game world, used by the quad tree for collisions and overlap checks. Use .set() instead of creating a new object!

staticworldDivisions:Int = 6

How many times the quad tree should divide the world on each axis. Generally, sparse collisions can have fewer divisons, while denser collision activity usually profits from more. Default value is 6.

Static methods

staticaddChildBelowMouse<T>(Child:T, IndexModifier:Int = 0):T

Regular DisplayObjects are normally displayed over the Flixel cursor and the Flixel debugger if simply added to stage. This function simplifies things by adding a DisplayObject directly below mouse level.

Parameters:

Child

The DisplayObject to add

IndexModifier

Amount to add to the index - makes sure the index stays within bounds.

Returns:

The added DisplayObject

staticinlinecollide(?ObjectOrGroup1:FlxBasic, ?ObjectOrGroup2:FlxBasic, ?NotifyCallback:Dynamic‑>Dynamic‑>Void):Bool

Call this function to see if one FlxObject collides with another within FlxG.worldBounds. Can be called with one object and one group, or two groups, or two objects, whatever floats your boat! For maximum performance try bundling a lot of objects together using a FlxGroup (or even bundling groups together!).

This function just calls FlxG.overlap and presets the ProcessCallback parameter to FlxObject.separate. To create your own collision logic, write your own ProcessCallback and use FlxG.overlap to set it up. NOTE: does NOT take objects' scrollFactor into account, all overlaps are checked in world space.

Parameters:

ObjectOrGroup1

The first object or group you want to check.

ObjectOrGroup2

The second object or group you want to check. If it is the same as the first, Flixel knows to just do a comparison within that group.

NotifyCallback

A function with two FlxObject parameters - e.g. onOverlap(object1:FlxObject, object2:FlxObject) - that is called if those two objects overlap.

Returns:

Whether any objects were successfully collided/separated.

staticinlineopenURL(URL:String, Target:String = "_blank"):Void

Opens a web page, by default a new tab or window. If the URL does not already start with "http://" or "https://", it gets added automatically.

Parameters:

URL

The address of the web page.

Target

"_blank", "_self", "_parent" or "_top"

staticoverlap(?ObjectOrGroup1:FlxBasic, ?ObjectOrGroup2:FlxBasic, ?NotifyCallback:Dynamic‑>Dynamic‑>Void, ?ProcessCallback:Dynamic‑>Dynamic‑>Bool):Bool

Call this function to see if one FlxObject overlaps another within FlxG.worldBounds. Can be called with one object and one group, or two groups, or two objects, whatever floats your boat! For maximum performance try bundling a lot of objects together using a FlxGroup (or even bundling groups together!).

NOTE: does NOT take objects' scrollFactor into account, all overlaps are checked in world space.

NOTE: this takes the entire area of FlxTilemaps into account (including "empty" tiles).

  Use `FlxTilemap#overlaps()` if you don't want that.

Parameters:

ObjectOrGroup1

The first object or group you want to check.

ObjectOrGroup2

The second object or group you want to check. If it is the same as the first, Flixel knows to just do a comparison within that group.

NotifyCallback

A function with two FlxObject parameters - e.g. onOverlap(object1:FlxObject, object2:FlxObject) - that is called if those two objects overlap.

ProcessCallback

A function with two FlxObject parameters - e.g. onOverlap(object1:FlxObject, object2:FlxObject) - that is called if those two objects overlap. If a ProcessCallback is provided, then NotifyCallback will only be called if ProcessCallback returns true for those objects!

Returns:

Whether any overlaps were detected.

staticinlinepixelPerfectOverlap(Sprite1:FlxSprite, Sprite2:FlxSprite, AlphaTolerance:Int = 255, ?Camera:FlxCamera):Bool

A pixel perfect collision check between two FlxSprite objects. It will do a bounds check first, and if that passes it will run a pixel perfect match on the intersecting area. Works with rotated and animated sprites. May be slow, so use it sparingly.

Parameters:

Sprite1

The first FlxSprite to test against.

Sprite2

The second FlxSprite to test again, sprite order is irrelevant.

AlphaTolerance

The tolerance value above which alpha pixels are included. Default to 255 (must be fully opaque for collision).

Camera

If the collision is taking place in a camera other than FlxG.camera (the default/current) then pass it here.

Returns:

Whether the sprites collide

staticinlineremoveChild<T>(Child:T):T

Removes a child from the Flixel display list, if it is part of it.

Parameters:

Child

The DisplayObject to add

Returns:

The removed DisplayObject

staticinlineresetGame():Void

Like hitting the reset button a game console, this will re-launch the game as if it just started.

staticinlineresetState():Void

Request a reset of the current game state. Calls switchState() with a new instance of the current state.

staticinlineresizeGame(Width:Int, Height:Int):Void

Resizes the game within the window by reapplying the current scale mode.

staticresizeWindow(Width:Int, Height:Int):Void

Resizes the window. Only works on desktop targets (Neko, Windows, Linux, Mac).

staticinlineswitchState(nextState:FlxState):Void

Attempts to switch from the current game state to nextState. The state switch is successful if switchTo() of the current state returns true.