Packageorg.flixel
Classpublic class FlxGame
InheritanceFlxGame Inheritance flash.display.Sprite

FlxGame is the heart of all flixel games, and contains a bunch of basic game loops and things. It is a long and sloppy file that you shouldn't have to worry about too much! It is basically only used to create your game object in the first place, after that FlxG and FlxState have all the useful stuff you actually need.



Public Properties
 PropertyDefined By
  _buffer : Bitmap
FlxGame
  _console : FlxConsole
FlxGame
  _created : Boolean
FlxGame
  _elapsed : Number
FlxGame
  _frame : Class
FlxGame
  _gameXOffset : int
FlxGame
  _gameYOffset : int
FlxGame
  _iState : Class
FlxGame
  pause : FlxGroup
Displayed whenever the game is paused.
FlxGame
  _paused : Boolean
FlxGame
  pauseOnFocusLost : Boolean
Should then game pause/result on focus changes?
FlxGame
  _screen : Sprite
FlxGame
  _soundTray : Sprite
FlxGame
  _soundTrayBars : Array
FlxGame
  _soundTrayTimer : Number
FlxGame
  _state : FlxState
FlxGame
  _total : uint
FlxGame
  useDefaultHotKeys : Boolean
Sets 0, -, and + to control the global volume and P to pause.
FlxGame
  _zeroPoint : Point
FlxGame
  _zoom : uint
FlxGame
Protected Properties
 PropertyDefined By
  junk : String
FlxGame
  SndBeep : Class
FlxGame
  SndFlixel : Class
FlxGame
Public Methods
 MethodDefined By
  
FlxGame(GameSizeX:uint, GameSizeY:uint, InitialState:Class, Zoom:uint = 2)
Game object constructor - sets up the basic properties of your game.
FlxGame
  
create(event:Event):void
Used to instantiate the guts of flixel once we have a valid pointer to the root.
FlxGame
  
pauseGame():void
Internal function to help with basic pause game functionality.
FlxGame
  
showSoundTray(Silent:Boolean = false):void
Makes the little volume tray slide out.
FlxGame
  
switchState(State:FlxState):void
Switch from one FlxState to another.
FlxGame
  
Internal function to help with basic pause game functionality.
FlxGame
Protected Methods
 MethodDefined By
  
addFrame(Frame:Class, ScreenOffsetX:uint, ScreenOffsetY:uint):FlxGame
Adds a frame around your game for presentation purposes (see Canabalt, Gravity Hook).
FlxGame
  
onFocus(event:Event = null):void
Internal event handler for input and focus.
FlxGame
  
onFocusLost(event:Event = null):void
Internal event handler for input and focus.
FlxGame
  
onKeyUp(event:KeyboardEvent):void
Internal event handler for input and focus.
FlxGame
  
update(event:Event):void
This is the main game loop.
FlxGame
Public Constants
 ConstantDefined By
  MAX_ELAPSED : Number = 0.0333
Essentially locks the framerate to 30 FPS minimum - any slower and you'll get slowdown instead of frameskip.
FlxGame
Property Detail
_bufferproperty
public var _buffer:Bitmap

_consoleproperty 
public var _console:FlxConsole

_createdproperty 
public var _created:Boolean

_elapsedproperty 
public var _elapsed:Number

_frameproperty 
public var _frame:Class

_gameXOffsetproperty 
public var _gameXOffset:int

_gameYOffsetproperty 
public var _gameYOffset:int

_iStateproperty 
public var _iState:Class

_pausedproperty 
public var _paused:Boolean

_screenproperty 
public var _screen:Sprite

_soundTrayproperty 
public var _soundTray:Sprite

_soundTrayBarsproperty 
public var _soundTrayBars:Array

_soundTrayTimerproperty 
public var _soundTrayTimer:Number

_stateproperty 
public var _state:FlxState

_totalproperty 
public var _total:uint

_zeroPointproperty 
public var _zeroPoint:Point

_zoomproperty 
public var _zoom:uint

junkproperty 
protected var junk:String

pauseproperty 
public var pause:FlxGroup

Displayed whenever the game is paused. Override with your own FlxLayer for hot custom pause action! Defaults to data.FlxPause.

pauseOnFocusLostproperty 
public var pauseOnFocusLost:Boolean

Should then game pause/result on focus changes?

The default value is true..

SndBeepproperty 
protected var SndBeep:Class

SndFlixelproperty 
protected var SndFlixel:Class

useDefaultHotKeysproperty 
public var useDefaultHotKeys:Boolean

Sets 0, -, and + to control the global volume and P to pause.

The default value is true.

Constructor Detail
FlxGame()Constructor
public function FlxGame(GameSizeX:uint, GameSizeY:uint, InitialState:Class, Zoom:uint = 2)

Game object constructor - sets up the basic properties of your game.

Parameters
GameSizeX:uint — The width of your game in pixels (e.g. 320).
 
GameSizeY:uint — The height of your game in pixels (e.g. 240).
 
InitialState:Class — The class name of the state you want to create and switch to first (e.g. MenuState).
 
Zoom:uint (default = 2) — The level of zoom (e.g. 2 means all pixels are now rendered twice as big).
Method Detail
addFrame()method
protected function addFrame(Frame:Class, ScreenOffsetX:uint, ScreenOffsetY:uint):FlxGame

Adds a frame around your game for presentation purposes (see Canabalt, Gravity Hook).

Parameters

Frame:Class — If you want you can add a little graphical frame to the outside edges of your game.
 
ScreenOffsetX:uint — Width in pixels of left side of frame.
 
ScreenOffsetY:uint — Height in pixels of top of frame.

Returns
FlxGame — This FlxGame instance.
create()method 
public function create(event:Event):void

Used to instantiate the guts of flixel once we have a valid pointer to the root.

Parameters

event:Event

onFocus()method 
protected function onFocus(event:Event = null):void

Internal event handler for input and focus.

Parameters

event:Event (default = null)

onFocusLost()method 
protected function onFocusLost(event:Event = null):void

Internal event handler for input and focus.

Parameters

event:Event (default = null)

onKeyUp()method 
protected function onKeyUp(event:KeyboardEvent):void

Internal event handler for input and focus.

Parameters

event:KeyboardEvent

pauseGame()method 
public function pauseGame():void

Internal function to help with basic pause game functionality.

showSoundTray()method 
public function showSoundTray(Silent:Boolean = false):void

Makes the little volume tray slide out.

Parameters

Silent:Boolean (default = false) — Whether or not it should beep.

switchState()method 
public function switchState(State:FlxState):void

Switch from one FlxState to another. Usually called from FlxG.

Parameters

State:FlxState — The class name of the state you want (e.g. PlayState)

unpauseGame()method 
public function unpauseGame():void

Internal function to help with basic pause game functionality.

update()method 
protected function update(event:Event):void

This is the main game loop. It controls all the updating and rendering.

Parameters

event:Event

Constant Detail
MAX_ELAPSEDConstant
public const MAX_ELAPSED:Number = 0.0333

Essentially locks the framerate to 30 FPS minimum - any slower and you'll get slowdown instead of frameskip.