C# Class flxSharp.flxSharp.System.FlxGame

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.
Show file Open project: jlorek/flxSharp Class Usage Examples

Protected Properties

Property Type Description
Focus Microsoft.Xna.Framework.Graphics.Texture2D
InitialState FlxState
SoundTray Microsoft.Xna.Framework.Graphics.Texture2D
SoundTrayBars System.Array
SoundTrayTimer float

Private Properties

Property Type Description
createFocusScreen void
createSoundTray void
showSoundTray void

Public Methods

Method Description
FlxGame ( FlxState State, int Width = 1280, int Height = 720, float Zoom = 1.0f, string ContentRootDirectory = "Content" ) : System

FlxGame constructor takes in the initial state and resolution of the screen.

FlxGame ( int gameSizeX, int gameSizeY, FlxState initialState, float zoom = 1.0f, int gameFramerate = 60, int flashFramerate, bool useSystemCursor = false ) : System

Instantiate a new game object.

Protected Methods

Method Description
Step ( ) : void

This is the main game update logic section. The onEnterFrame() handler is in charge of calling this the appropriate number of times each frame. This block handles state changes, replays, all that good stuff.

create ( EventArgs flashEvent ) : void

Used to instantiate the guts of the flixel game object once we have a valid reference to the root.

draw ( ) : void

Goes through the game state and draws all the game objects and special effects.

onEnterFrame ( EventArgs eventArgs = null ) : void

Handles the onEnterFrame call and figures out how many updates and draw calls to do.

onFocus ( EventArgs eventArgs = null ) : void

Internal event handler for input and focus.

onFocusLost ( EventArgs eventArgs = null ) : void

Internal event handler for input and focus.

onKeyDown ( EventArgs keyboardEvent ) : void

Internal event handler for input and focus.

onKeyUp ( EventArgs keyboardEvent ) : void

Internal event handler for input and focus.

onMouseDown ( EventArgs mouseEvent ) : void

Internal event handler for input and focus.

onMouseUp ( EventArgs mouseEvent ) : void

Internal event handler for input and focus.

onMouseWheel ( EventArgs mouseEvent ) : void

Internal event handler for input and focus.

switchState ( ) : void

If there is a state change requested during the update loop, this function handles actual destroying the old state and related processes, and calls creates on the new state and plugs it into the game object.

update ( ) : void

This function is called by step() and updates the actual game state. May be called multiple times per "frame" or draw call.

updateSoundTray ( float ms ) : void

This function just updates the soundtray object.

Private Methods

Method Description
createFocusScreen ( ) : void

Sets up the darkened overlay with the big white "play" button that appears when a flixel game loses focus.

createSoundTray ( ) : void

Sets up the "sound tray", the little volume meter that pops down sometimes.

showSoundTray ( bool silent = false ) : void

Makes the little volume tray slide out.

Method Details

FlxGame() public method

FlxGame constructor takes in the initial state and resolution of the screen.
public FlxGame ( FlxState State, int Width = 1280, int Height = 720, float Zoom = 1.0f, string ContentRootDirectory = "Content" ) : System
State FlxState The state you want to load
Width int The width of the screen
Height int The height of the screen
Zoom float
ContentRootDirectory string The directory of your content. It is set automatically by default but you can change it if you want to.
return System

FlxGame() public method

Instantiate a new game object.
public FlxGame ( int gameSizeX, int gameSizeY, FlxState initialState, float zoom = 1.0f, int gameFramerate = 60, int flashFramerate, bool useSystemCursor = false ) : System
gameSizeX int The width of your game in game pixels, not necessarily final display pixels (see Zoom).
gameSizeY int The height of your game in game pixels, not necessarily final display pixels (see Zoom).
initialState FlxState The class name of the state you want to create and switch to first (e.g. MenuState).
zoom float The default level of zoom for the game's cameras (e.g. 2 = all pixels are now drawn at 2x). Default = 1.
gameFramerate int How frequently the game should update (default is 60 times per second).
flashFramerate int Sets the actual display framerate for Flash player (default is 30 times per second).
useSystemCursor bool Whether to use the default OS mouse pointer, or to use custom flixel ones.
return System

Step() protected method

This is the main game update logic section. The onEnterFrame() handler is in charge of calling this the appropriate number of times each frame. This block handles state changes, replays, all that good stuff.
protected Step ( ) : void
return void

create() protected method

Used to instantiate the guts of the flixel game object once we have a valid reference to the root.
protected create ( EventArgs flashEvent ) : void
flashEvent System.EventArgs Just a Flash system event, not too important for our purposes.
return void

draw() protected method

Goes through the game state and draws all the game objects and special effects.
protected draw ( ) : void
return void

onEnterFrame() protected method

Handles the onEnterFrame call and figures out how many updates and draw calls to do.
protected onEnterFrame ( EventArgs eventArgs = null ) : void
eventArgs System.EventArgs Flash event.
return void

onFocus() protected method

Internal event handler for input and focus.
protected onFocus ( EventArgs eventArgs = null ) : void
eventArgs System.EventArgs Flash event.
return void

onFocusLost() protected method

Internal event handler for input and focus.
protected onFocusLost ( EventArgs eventArgs = null ) : void
eventArgs System.EventArgs Flash event.
return void

onKeyDown() protected method

Internal event handler for input and focus.
protected onKeyDown ( EventArgs keyboardEvent ) : void
keyboardEvent System.EventArgs Flash keyboard event.
return void

onKeyUp() protected method

Internal event handler for input and focus.
protected onKeyUp ( EventArgs keyboardEvent ) : void
keyboardEvent System.EventArgs Flash keyboard event.
return void

onMouseDown() protected method

Internal event handler for input and focus.
protected onMouseDown ( EventArgs mouseEvent ) : void
mouseEvent System.EventArgs Flash mouse event.
return void

onMouseUp() protected method

Internal event handler for input and focus.
protected onMouseUp ( EventArgs mouseEvent ) : void
mouseEvent System.EventArgs Flash mouse event.
return void

onMouseWheel() protected method

Internal event handler for input and focus.
protected onMouseWheel ( EventArgs mouseEvent ) : void
mouseEvent System.EventArgs Flash mouse event.
return void

switchState() protected method

If there is a state change requested during the update loop, this function handles actual destroying the old state and related processes, and calls creates on the new state and plugs it into the game object.
protected switchState ( ) : void
return void

update() protected method

This function is called by step() and updates the actual game state. May be called multiple times per "frame" or draw call.
protected update ( ) : void
return void

updateSoundTray() protected method

This function just updates the soundtray object.
protected updateSoundTray ( float ms ) : void
ms float
return void

Property Details

Focus protected property

The "focus lost" screen (see createFocusScreen()).
protected Texture2D,Microsoft.Xna.Framework.Graphics Focus
return Microsoft.Xna.Framework.Graphics.Texture2D

InitialState protected property

Class type of the initial/first game state for the game, usually MenuState or something like that.
protected FlxState InitialState
return FlxState

SoundTray protected property

The sound tray display container (see createSoundTray()).
protected Texture2D,Microsoft.Xna.Framework.Graphics SoundTray
return Microsoft.Xna.Framework.Graphics.Texture2D

SoundTrayBars protected property

Helps display the volume bars on the sound tray.
protected Array,System SoundTrayBars
return System.Array

SoundTrayTimer protected property

Helps us auto-hide the sound tray after a volume change.
protected float SoundTrayTimer
return float