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
  _framerate : uint
FlxGame
  _frameratePaused : uint
FlxGame
  _gameXOffset : int
FlxGame
  _gameYOffset : int
FlxGame
  _iState : Class
FlxGame
  pause : FlxGroup
Displayed whenever the game is paused.
FlxGame
  _paused : Boolean
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
  
unpauseGame():void
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
  
onKeyDown(event:KeyboardEvent):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
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
_framerateproperty 
public var _framerate:uint
_frameratePausedproperty 
public var _frameratePaused:uint
_gameXOffsetproperty 
public var _gameXOffset:int
_gameYOffsetproperty 
public var _gameYOffset:int
_iStateproperty 
public var _iState:Class
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.

_pausedproperty 
public var _paused:Boolean
_screenproperty 
public var _screen:Sprite
SndBeepproperty 
protected var SndBeep:Class
SndFlixelproperty 
protected var SndFlixel:Class
_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
useDefaultHotKeysproperty 
public var useDefaultHotKeys:Boolean

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

The default value is true.

_zeroPointproperty 
public var _zeroPoint:Point
_zoomproperty 
public var _zoom:uint
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)
onKeyDown()method 
protected function onKeyDown(event:KeyboardEvent):void

Internal event handler for input and focus.

Parameters
event:KeyboardEvent
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