Global helper class for audio, input, the camera system, the debugger and other global properties.
Static variables
staticread onlyVERSION:FlxVersion = new FlxVersion(5, 8, 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"
.
staticanimationTimeScale:Float = 1.0
How fast or slow animations should pass in the game; default is 1.0
.
5.5.0
.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 onlyheight:Int
The height of the screen in game pixels. Read-only, use resizeGame()
to change.
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.
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 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.
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.
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!
staticread onlyswipes:Array<FlxSwipe> = []
Contains all "swipes" from both mouse and touch input that have just ended.
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 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 DisplayObject
s 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 |
---|---|
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 |
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 |
|
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 FlxTilemap
s 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 |
processCallback | A function with two |
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 |
---|---|
sprite2 | The second |
alphaTolerance | The tolerance value above which alpha pixels are included.
Default to |
camera | If the collision is taking place in a camera other than
|
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 |
---|
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: |
---|