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

Static variables

@:value(new FlxVersion(5, 6, 2))staticread onlyVERSION:FlxVersion = new FlxVersion(5, 6, 2)

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".

@:value(1.0)staticanimationTimeScale:Float = 1.0

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

Available since

5.5.0

.

@:value(true)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.

@:value(new BitmapFrontEnd())staticread onlybitmap:BitmapFrontEnd = new BitmapFrontEnd()

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

@:value(new BitmapLogFrontEnd())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.

@:value(new CameraFrontEnd())staticread onlycameras:CameraFrontEnd = new CameraFrontEnd()

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

@:value(new ConsoleFrontEnd())staticread onlyconsole:ConsoleFrontEnd = new ConsoleFrontEnd()

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

@:value(new DebuggerFrontEnd())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!

@:value(0)@:allow(flixel.FlxGame.updateElapsed)staticread onlyelapsed:Float = 0

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

@:value(true)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.

@:allow(flixel.system.scaleModes)staticread onlyheight:Int

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

@:value(0)staticread onlyinitialHeight:Int = 0

@:value(0)staticread onlyinitialWidth:Int = 0

@:value(new InputFrontEnd())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().

@:value(new LogFrontEnd())staticread onlylog:LogFrontEnd = new LogFrontEnd()

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

@:value(0.1)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.

@:value(new FlxRandom())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

@:value(new FlxSave())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!

@:value(new RatioScaleMode())staticscaleMode:BaseScaleMode = new RatioScaleMode()

The scale mode the game should use. HaxeFlixel includes several available scale modes, which are located in flixel.system.scaleModes. However, you may also create a class which extends BaseScaleMode, and override its behavior according to your needs.

@:value(new SignalFrontEnd())staticread onlysignals:SignalFrontEnd = new SignalFrontEnd()

Contains system-wide signals like gameResized or preStateSwitch.

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!

@:value([])staticread onlyswipes:Array<FlxSwipe> = []

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

@:value(1.0)statictimeScale:Float = 1.0

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.

@:value(new WatchFrontEnd())staticread onlywatch:WatchFrontEnd = new WatchFrontEnd()

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

@:allow(flixel.system.scaleModes)staticread onlywidth:Int

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

@:value(FlxRect.get())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!

@:value(6)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

@:value({ indexModifier : 0 })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.

@:value({ target : "_blank" })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.

@:value({ alphaTolerance : 255 })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 on 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:NextState):Void

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

Parameters:

nextState

A constructor for the initial state, ex: PlayState.new or ()->new PlayState(). Note: Before Flixel 5.6.0, this took a FlxState instance, this is still available, for backwards compatibility.