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
  _bmpBack : Bitmap
FlxGame
  _bmpFront : Bitmap
FlxGame
  _buffer : Sprite
FlxGame
  _console : FlxConsole
FlxGame
  _created : Boolean
FlxGame
  _elapsed : Number
FlxGame
  _flipped : Boolean
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
  _r : Rectangle
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
  
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
  
onEnterFrame(event:Event):void
This is the main game loop, but only once creation and logo playback is finished.
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
Public Constants
 ConstantDefined by
  MAX_ELAPSED : Number = 0.0333
Essentially locks the framerate to 30 FPS minimum
FlxGame
Property detail
_bmpBackproperty
public var _bmpBack:Bitmap
_bmpFrontproperty 
public var _bmpFront:Bitmap
_bufferproperty 
public var _buffer:Sprite
_consoleproperty 
public var _console:FlxConsole
_createdproperty 
public var _created:Boolean
_elapsedproperty 
public var _elapsed:Number
_flippedproperty 
public var _flipped:Boolean
_frameproperty 
public var _frame:Class
_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
_rproperty 
public var _r:Rectangle
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.
onEnterFrame()method 
protected function onEnterFrame(event:Event):void

This is the main game loop, but only once creation and logo playback is finished.

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.

Constant detail
MAX_ELAPSEDconstant
public const MAX_ELAPSED:Number = 0.0333

Essentially locks the framerate to 30 FPS minimum