Package | org.flixel |
Class | public class FlxG |
Inheritance | FlxG ![]() |
Property | Defined By | ||
---|---|---|---|
bgColor : uint [static] | FlxG | ||
camera : FlxCamera [static]
By default this just refers to the first entry in the cameras array
declared above, but you can do what you like with it. | FlxG | ||
cameras : Array [static]
An array of FlxCamera objects that are used to draw stuff. | FlxG | ||
debug : Boolean [static]
Whether you are running in Debug or Release mode. | FlxG | ||
elapsed : Number [static]
Represents the amount of time in seconds that passed since last frame. | FlxG | ||
flashFramerate : Number [static]
How many times you want your game to update each second. | FlxG | ||
framerate : Number [static]
How many times you want your game to update each second. | FlxG | ||
_game : FlxGame [static]
Internal tracker for game object (so we can pause and unpause)
| FlxG | ||
globalSeed : Number [static]
The global random number generator seed (for deterministic behavior in recordings and saves). | FlxG | ||
height : uint [static]
The height of the screen in game pixels. | FlxG | ||
keys : Keyboard [static]
A reference to a FlxKeyboard object. | FlxG | ||
level : int [static] | FlxG | ||
levels : Array [static]
FlxG.levels and FlxG.scores are generic
global variables that can be used for various cross-state stuff. | FlxG | ||
LIBRARY_MAJOR_VERSION : uint = 2 [static]
Assign a major version to your library. | FlxG | ||
LIBRARY_MINOR_VERSION : uint = 50 [static]
Assign a minor version to your library. | FlxG | ||
LIBRARY_NAME : String = flixel [static]
If you build and maintain your own version of flixel,
you can give it your own name here. | FlxG | ||
mobile : Boolean [static]
Setting this to true will disable/skip stuff that isn't necessary for mobile platforms like Android. | FlxG | ||
mouse : Mouse [static]
A reference to a FlxMouse object. | FlxG | ||
music : FlxSound [static]
A handy container for a background music object. | FlxG | ||
mute : Boolean [static]
Whether or not the game sounds are muted. | FlxG | ||
paused : Boolean [static]
Handy shared variable for implementing your own pause behavior. | FlxG | ||
save : int [static] | FlxG | ||
saves : Array [static]
FlxG.saves is a generic bucket for storing
FlxSaves so you can access them whenever you want. | FlxG | ||
score : int [static] | FlxG | ||
scores : Array [static] | FlxG | ||
sounds : FlxGroup [static]
A list of all the sounds being played in the game. | FlxG | ||
stage : Stage [static] [read-only]
Retrieves the Flash stage object (required for event listeners)
| FlxG | ||
state : FlxState [static] [read-only]
Access the current game state from anywhere. | FlxG | ||
timeScale : Number [static]
How fast or slow time should pass in the game; default is 1.0. | FlxG | ||
volume : Number [static]
Set volume to a number between 0 and 1 to change the global volume. | FlxG | ||
width : uint [static]
The width of the screen in game pixels. | FlxG | ||
worldBounds : FlxRect [static]
The dimensions of the game world, used by the quad tree for collisions and overlap checks. | FlxG | ||
worldDivisions : uint [static]
How many times the quad tree should divide the world on each axis. | FlxG |
Property | Defined By | ||
---|---|---|---|
_cache : Object [static]
Internal storage system to prevent graphics from being used repeatedly in memory. | FlxG | ||
_cameraRect : Rectangle [static]
Internal helper variable for clearing the cameras each frame. | FlxG | ||
_volume : Number [static]
Internal volume level, used for global sound control. | FlxG |
Method | Defined By | ||
---|---|---|---|
addBitmap(Graphic:Class, Reverse:Boolean = false, Unique:Boolean = false, Key:String = null):BitmapData [static]
Loads a bitmap from a file, caches it, and generates a horizontally flipped version if necessary. | FlxG | ||
[static] | FlxG | ||
checkBitmapCache(Key:String):Boolean [static]
Check the local bitmap cache to see if a bitmap with this key has been loaded already. | FlxG | ||
clearBitmapCache():void [static] | FlxG | ||
createBitmap(Width:uint, Height:uint, Color:uint, Unique:Boolean = false, Key:String = null):BitmapData [static]
Generates a new BitmapData object (a colored square) and caches it. | FlxG | ||
destroySounds(ForceDestroy:Boolean = false):void [static]
Called by FlxGame on state changes to stop and destroy sounds. | FlxG | ||
fade(Color:uint = 0xffffffff, Duration:Number = 1, OnComplete:Function = null, Force:Boolean = false):void [static]
The screen is gradually filled with this color. | FlxG | ||
flash(Color:uint = 0xffffffff, Duration:Number = 1, OnComplete:Function = null, Force:Boolean = false):void [static]
All screens are filled with this color and gradually return to normal. | FlxG | ||
getLibraryName():String [static] | FlxG | ||
getRandom(Objects:Array):Object [static] | FlxG | ||
[static]
Called by FlxGame to set up FlxG during FlxGame's constructor. | FlxG | ||
loadReplay(Data:String, State:FlxState = null, CancelKeys:Array = null, Timeout:Number, Callback:Function = null):void [static]
Load replay data from a string and play it back. | FlxG | ||
lockCameras():void [static] | FlxG | ||
log(Data:Object):void [static]
Log data to the debugger. | FlxG | ||
pauseSounds():void [static]
Pause all sounds currently playing. | FlxG | ||
[static]
Creates a new sound object from an embedded Class object. | FlxG | ||
playMusic(Music:Class, Volume:Number = 1.0):void [static]
Set up and play a looping background soundtrack. | FlxG | ||
playSounds():void [static]
Resume playing existing sounds. | FlxG | ||
random():Number [static]
Generates a random number. | FlxG | ||
recordReplay(StandardMode:Boolean = true):void [static] | FlxG | ||
reloadReplay(StandardMode:Boolean = true):void [static] | FlxG | ||
reset():void [static] | FlxG | ||
resetCameras(NewCamera:FlxCamera = null):void [static] | FlxG | ||
resetDebuggerLayout():void [static]
Just resets the debugger windows to whatever the sizes and positions of the selected layout are. | FlxG | ||
resetGame():void [static]
Like hitting the reset button on a game console, this will re-launch the game as if it just started. | FlxG | ||
resetInput():void [static]
Reset the input helper objects (useful when changing screens or states)
| FlxG | ||
resetState():void [static] | FlxG | ||
setDebuggerLayout(Layout:uint):void [static]
Change the way the debugger's windows are laid out. | FlxG | ||
shake(Intensity:Number = 0.05, Duration:Number = 0.5, OnComplete:Function = null, Force:Boolean = true, Direction:uint):void [static]
A simple screen-shake effect. | FlxG | ||
shuffle(Objects:Array, HowManyTimes:uint):Array [static]
Shuffles the entries in an array into a new random order. | FlxG | ||
stopRecording():String [static] | FlxG | ||
stopReplay():void [static] | FlxG | ||
[static]
Creates a new sound object from a URL. | FlxG | ||
switchState(State:FlxState):void [static]
Switch from the current game state to the one specified here. | FlxG | ||
unlockCameras():void [static] | FlxG | ||
unwatch(AnyObject:Object, VariableName:String = null):void [static]
Remove a variable from the watch list in the debugger. | FlxG | ||
updateCameras():void [static] | FlxG | ||
updateInput():void [static]
Calls update on the keyboard and mouse input tracking objects. | FlxG | ||
updateSounds():void [static]
Called by the game loop to make sure the sounds get updated each frame. | FlxG | ||
watch(AnyObject:Object, VariableName:String, DisplayName:String = null):void [static]
Add a variable to the watch list in the debugger. | FlxG |
Constant | Defined By | ||
---|---|---|---|
DEBUGGER_BIG : uint = 2 [static] | FlxG | ||
DEBUGGER_LEFT : uint = 4 [static] | FlxG | ||
DEBUGGER_MICRO : uint = 1 [static] | FlxG | ||
DEBUGGER_RIGHT : uint = 5 [static] | FlxG | ||
DEBUGGER_STANDARD : uint = 0 [static] | FlxG | ||
DEBUGGER_TOP : uint = 3 [static] | FlxG |
_cache | property |
protected static var _cache:Object
Internal storage system to prevent graphics from being used repeatedly in memory.
_cameraRect | property |
protected static var _cameraRect:Rectangle
Internal helper variable for clearing the cameras each frame.
_game | property |
public static var _game:FlxGame
Internal tracker for game object (so we can pause and unpause)
_volume | property |
protected static var _volume:Number
Internal volume level, used for global sound control.
bgColor | property |
bgColor:uint
public static function get bgColor():uint
public static function set bgColor(value:uint):void
camera | property |
public static var camera:FlxCamera
By default this just refers to the first entry in the cameras array declared above, but you can do what you like with it.
cameras | property |
public static var cameras:Array
An array of FlxCamera
objects that are used to draw stuff.
By default flixel creates one camera the size of the screen.
debug | property |
public static var debug:Boolean
Whether you are running in Debug or Release mode.
Set automatically by FlxFactory
during startup.
elapsed | property |
public static var elapsed:Number
Represents the amount of time in seconds that passed since last frame.
flashFramerate | property |
flashFramerate:Number
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 Flash Player framerate!
public static function get flashFramerate():Number
public static function set flashFramerate(value:Number):void
framerate | property |
framerate:Number
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 Flash Player framerate!
public static function get framerate():Number
public static function set framerate(value:Number):void
globalSeed | property |
public static var globalSeed:Number
The global random number generator seed (for deterministic behavior in recordings and saves).
height | property |
public static var height:uint
The height of the screen in game pixels.
keys | property |
public static var keys:Keyboard
A reference to a FlxKeyboard
object. Important for input!
level | property |
public static var level:int
levels | property |
public static var levels:Array
FlxG.levels
and FlxG.scores
are generic
global variables that can be used for various cross-state stuff.
LIBRARY_MAJOR_VERSION | property |
public static var LIBRARY_MAJOR_VERSION:uint = 2
Assign a major version to your library. Appears before the decimal in the console.
LIBRARY_MINOR_VERSION | property |
public static var LIBRARY_MINOR_VERSION:uint = 50
Assign a minor version to your library. Appears after the decimal in the console.
LIBRARY_NAME | property |
public static var LIBRARY_NAME:String = flixel
If you build and maintain your own version of flixel, you can give it your own name here. Appears in the console.
mobile | property |
public static var mobile:Boolean
Setting this to true will disable/skip stuff that isn't necessary for mobile platforms like Android. [BETA]
mouse | property |
public static var mouse:Mouse
A reference to a FlxMouse
object. Important for input!
music | property |
public static var music:FlxSound
A handy container for a background music object.
mute | property |
public static var mute:Boolean
Whether or not the game sounds are muted.
paused | property |
public static var paused:Boolean
Handy shared variable for implementing your own pause behavior.
save | property |
public static var save:int
saves | property |
public static var saves:Array
FlxG.saves
is a generic bucket for storing
FlxSaves so you can access them whenever you want.
score | property |
public static var score:int
scores | property |
public static var scores:Array
sounds | property |
public static var sounds:FlxGroup
A list of all the sounds being played in the game.
stage | property |
stage:Stage
[read-only] Retrieves the Flash stage object (required for event listeners)
public static function get stage():Stage
state | property |
state:FlxState
[read-only] Access the current game state from anywhere.
public static function get state():FlxState
timeScale | property |
public static var timeScale:Number
How fast or slow time should pass in the game; default is 1.0.
volume | property |
volume:Number
Set volume
to a number between 0 and 1 to change the global volume.
The default value is 0.5
.
public static function get volume():Number
public static function set volume(value:Number):void
width | property |
public static var width:uint
The width of the screen in game pixels.
worldBounds | property |
public static var worldBounds:FlxRect
The dimensions of the game world, used by the quad tree for collisions and overlap checks.
worldDivisions | property |
public static var worldDivisions:uint
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.
addBitmap | () | method |
public static function addBitmap(Graphic:Class, Reverse:Boolean = false, Unique:Boolean = false, Key:String = null):BitmapData
Loads a bitmap from a file, caches it, and generates a horizontally flipped version if necessary.
Parameters
Graphic:Class — The image file that you want to load.
| |
Reverse:Boolean (default = false ) — Whether to generate a flipped version.
| |
Unique:Boolean (default = false )
| |
Key:String (default = null )
|
BitmapData — The BitmapData we just created.
|
addCamera | () | method |
public static function addCamera(NewCamera:FlxCamera):FlxCamera
Parameters
NewCamera:FlxCamera |
FlxCamera |
checkBitmapCache | () | method |
public static function checkBitmapCache(Key:String):Boolean
Check the local bitmap cache to see if a bitmap with this key has been loaded already.
Parameters
Key:String — The string key identifying the bitmap.
|
Boolean — Whether or not this file can be found in the cache.
|
clearBitmapCache | () | method |
public static function clearBitmapCache():void
createBitmap | () | method |
public static function createBitmap(Width:uint, Height:uint, Color:uint, Unique:Boolean = false, Key:String = null):BitmapData
Generates a new BitmapData
object (a colored square) and caches it.
Parameters
Width:uint — How wide the square should be.
| |
Height:uint — How high the square should be.
| |
Color:uint — What color the square should be (0xAARRGGBB)
| |
Unique:Boolean (default = false )
| |
Key:String (default = null )
|
BitmapData — The BitmapData we just created.
|
destroySounds | () | method |
public static function destroySounds(ForceDestroy:Boolean = false):void
Called by FlxGame on state changes to stop and destroy sounds.
Parameters
ForceDestroy:Boolean (default = false ) — Kill sounds even if they're flagged survive .
|
fade | () | method |
public static function fade(Color:uint = 0xffffffff, Duration:Number = 1, OnComplete:Function = null, Force:Boolean = false):void
The screen is gradually filled with this color.
Parameters
Color:uint (default = 0xffffffff ) — The color you want to use.
| |
Duration:Number (default = 1 ) — How long it takes for the fade to finish.
| |
OnComplete:Function (default = null ) — A function you want to run when the fade finishes.
| |
Force:Boolean (default = false ) — Force the effect to reset.
|
flash | () | method |
public static function flash(Color:uint = 0xffffffff, Duration:Number = 1, OnComplete:Function = null, Force:Boolean = false):void
All screens are filled with this color and gradually return to normal.
Parameters
Color:uint (default = 0xffffffff ) — The color you want to use.
| |
Duration:Number (default = 1 ) — How long it takes for the flash to fade.
| |
OnComplete:Function (default = null ) — A function you want to run when the flash finishes.
| |
Force:Boolean (default = false ) — Force the effect to reset.
|
getLibraryName | () | method |
public static function getLibraryName():String
ReturnsString |
getRandom | () | method |
public static function getRandom(Objects:Array):Object
Parameters
Objects:Array |
Object |
init | () | method |
public static function init(Game:FlxGame, Width:uint, Height:uint, Zoom:Number):void
Called by FlxGame
to set up FlxG
during FlxGame
's constructor.
Parameters
Game:FlxGame | |
Width:uint | |
Height:uint | |
Zoom:Number |
loadReplay | () | method |
public static function loadReplay(Data:String, State:FlxState = null, CancelKeys:Array = null, Timeout:Number, Callback:Function = null):void
Load replay data from a string and play it back.
Parameters
Data:String — The replay that you want to load.
| |
State:FlxState (default = null ) — Optional parameter: if you recorded a state-specific demo or cutscene, pass a new instance of that state here.
| |
CancelKeys:Array (default = null ) — Optional parameter: an array of string names of keys (see FlxKeyboard) that can be pressed to cancel the playback, e.g. ["ESCAPE","ENTER"]. Also accepts 2 custom key names: "ANY" and "MOUSE" (fairly self-explanatory I hope!).
| |
Timeout:Number (default = NaN ) — Optional parameter: set a time limit for the replay. CancelKeys will override this if pressed.
| |
Callback:Function (default = null ) — Optional parameter: if set, called when the replay finishes. Running to the end, CancelKeys, and Timeout will all trigger Callback(), but only once, and CancelKeys and Timeout will NOT call FlxG.stopReplay() if Callback is set!
|
lockCameras | () | method |
public static function lockCameras():void
log | () | method |
public static function log(Data:Object):void
Log data to the debugger.
Parameters
Data:Object — Anything you want to log to the console.
|
pauseSounds | () | method |
public static function pauseSounds():void
Pause all sounds currently playing.
play | () | method |
public static function play(EmbeddedSound:Class, Volume:Number = 1.0, Looped:Boolean = false):FlxSound
Creates a new sound object from an embedded Class
object.
Parameters
EmbeddedSound:Class — The sound you want to play.
| |
Volume:Number (default = 1.0 ) — How loud to play it (0 to 1).
| |
Looped:Boolean (default = false ) — Whether or not to loop this sound.
|
FlxSound — A FlxSound object.
|
playMusic | () | method |
public static function playMusic(Music:Class, Volume:Number = 1.0):void
Set up and play a looping background soundtrack.
Parameters
Music:Class — The sound file you want to loop in the background.
| |
Volume:Number (default = 1.0 ) — How loud the sound should be, from 0 to 1.
|
playSounds | () | method |
public static function playSounds():void
Resume playing existing sounds.
random | () | method |
public static function random():Number
Generates a random number. Deterministic, meaning safe to use if you want to record replays in random environments.
ReturnsNumber — A Number between 0 and 1.
|
recordReplay | () | method |
public static function recordReplay(StandardMode:Boolean = true):void
Parameters
StandardMode:Boolean (default = true )
|
reloadReplay | () | method |
public static function reloadReplay(StandardMode:Boolean = true):void
Parameters
StandardMode:Boolean (default = true )
|
reset | () | method |
public static function reset():void
resetCameras | () | method |
public static function resetCameras(NewCamera:FlxCamera = null):void
Parameters
NewCamera:FlxCamera (default = null )
|
resetDebuggerLayout | () | method |
public static function resetDebuggerLayout():void
Just resets the debugger windows to whatever the sizes and positions of the selected layout are.
resetGame | () | method |
public static function resetGame():void
Like hitting the reset button on a game console, this will re-launch the game as if it just started.
resetInput | () | method |
public static function resetInput():void
Reset the input helper objects (useful when changing screens or states)
resetState | () | method |
public static function resetState():void
setDebuggerLayout | () | method |
public static function setDebuggerLayout(Layout:uint):void
Change the way the debugger's windows are laid out.
Parameters
Layout:uint — Check aux/FlxDebugger for helpful constants like FlxDebugger.LEFT, etc.
|
shake | () | method |
public static function shake(Intensity:Number = 0.05, Duration:Number = 0.5, OnComplete:Function = null, Force:Boolean = true, Direction:uint):void
A simple screen-shake effect.
Parameters
Intensity:Number (default = 0.05 ) — Percentage of screen size representing the maximum distance that the screen can move while shaking.
| |
Duration:Number (default = 0.5 ) — The length in seconds that the shaking effect should last.
| |
OnComplete:Function (default = null ) — A function you want to run when the shake effect finishes.
| |
Force:Boolean (default = true ) — Force the effect to reset (default = true, unlike flash() and fade()!).
| |
Direction:uint (default = NaN ) — Whether to shake on both axes, just up and down, or just side to side (use class constants SHAKE_BOTH_AXES, SHAKE_VERTICAL_ONLY, or SHAKE_HORIZONTAL_ONLY).
|
shuffle | () | method |
public static function shuffle(Objects:Array, HowManyTimes:uint):Array
Shuffles the entries in an array into a new random order.
Parameters
Objects:Array — A Flash Array object containing...stuff.
| |
HowManyTimes:uint — How many swaps to perform during the shuffle operation. Good rule of thumb is 2-4 times as many objects are in the list.
|
Array — The same Flash Array object that you passed in in the first place.
|
stopRecording | () | method |
public static function stopRecording():String
ReturnsString |
stopReplay | () | method |
public static function stopReplay():void
stream | () | method |
public static function stream(URL:String, Volume:Number = 1.0, Looped:Boolean = false):FlxSound
Creates a new sound object from a URL.
Parameters
URL:String — The sound you want to play.
| |
Volume:Number (default = 1.0 ) — How loud to play it (0 to 1).
| |
Looped:Boolean (default = false ) — Whether or not to loop this sound.
|
FlxSound — A FlxSound object.
|
switchState | () | method |
public static function switchState(State:FlxState):void
Switch from the current game state to the one specified here.
Parameters
State:FlxState |
unlockCameras | () | method |
public static function unlockCameras():void
unwatch | () | method |
public static function unwatch(AnyObject:Object, VariableName:String = null):void
Remove a variable from the watch list in the debugger. Don't pass a Variable Name to remove all watched variables for the specified object.
Parameters
AnyObject:Object — A reference to any object in your game, e.g. Player or Robot or this.
| |
VariableName:String (default = null ) — The name of the variable you want to watch, in quotes, as a string: e.g. "speed" or "health".
|
updateCameras | () | method |
public static function updateCameras():void
updateInput | () | method |
public static function updateInput():void
Calls update on the keyboard and mouse input tracking objects.
updateSounds | () | method |
public static function updateSounds():void
Called by the game loop to make sure the sounds get updated each frame.
watch | () | method |
public static function watch(AnyObject:Object, VariableName:String, DisplayName:String = null):void
Add a variable to the watch list in the debugger. This lets you see the value of the variable all the time.
Parameters
AnyObject:Object — A reference to any object in your game, e.g. Player or Robot or this.
| |
VariableName:String — The name of the variable you want to watch, in quotes, as a string: e.g. "speed" or "health".
| |
DisplayName:String (default = null ) — Optional, display your own string instead of the class name + variable name: e.g. "enemy count".
|
DEBUGGER_BIG | Constant |
public static const DEBUGGER_BIG:uint = 2
DEBUGGER_LEFT | Constant |
public static const DEBUGGER_LEFT:uint = 4
DEBUGGER_MICRO | Constant |
public static const DEBUGGER_MICRO:uint = 1
DEBUGGER_RIGHT | Constant |
public static const DEBUGGER_RIGHT:uint = 5
DEBUGGER_STANDARD | Constant |
public static const DEBUGGER_STANDARD:uint = 0
DEBUGGER_TOP | Constant |
public static const DEBUGGER_TOP:uint = 3