C# Class XnaFlixel.FlxG

This is a global helper class full of useful functions for audio, input, basic info, and the camera system among other things.
显示文件 Open project: jsbeckr/XnaFlixel

Public Properties

Property Type Description
Game Microsoft.Xna.Framework.Game
GameTime Microsoft.Xna.Framework.GameTime
LIBRARY_MAJOR_VERSION uint
LIBRARY_MINOR_VERSION uint
LIBRARY_NAME string
autoHandlePause bool
backColor Microsoft.Xna.Framework.Color
debug bool
elapsed float
fade FlxFade
flash FlxFlash
followLead Microsoft.Xna.Framework.Vector2
followLerp float
followMax Microsoft.Xna.Framework.Point
followMin Microsoft.Xna.Framework.Point
followTarget FlxObject
gamepads XnaFlixel.data.FlxGamepad
getTimer uint
height int
keys FlxKeyboard
level int
levels List
maxElapsed float
mobile bool
mouse FlxMouse
music FlxSound
quake XnaFlixel.data.FlxQuake
save int
saves List
score int
scores List
scroll Microsoft.Xna.Framework.Vector2
showBounds bool
sounds List
timeScale float
width int

Protected Properties

Property Type Description
_flxGame FlxGame
_mute bool
_pause bool
_scrollTarget Microsoft.Xna.Framework.Vector2
_volume float

Public Methods

Method Description
LoadContent ( GraphicsDevice gd ) : void
follow ( FlxObject Target, float Lerp ) : void
followAdjust ( float LeadX, float LeadY ) : void
followBounds ( int MinX, int MinY, int MaxX, int MaxY ) : void

Specify the boundaries of the level or where the camera is allowed to move. @param MinX The smallest X value of your level (usually 0). @param MinY The smallest Y value of your level (usually 0). @param MaxX The largest X value of your level (usually the level width). @param MaxY The largest Y value of your level (usually the level height). @param UpdateWorldBounds Whether the quad tree's dimensions should be updated to match.

followBounds ( int MinX, int MinY, int MaxX, int MaxY, bool UpdateWorldBounds ) : void
getMuteValue ( ) : int

Get a number that represents the mute state that we can multiply into a sound transform. @return An unsigned integer - 0 if muted, 1 if not muted.

log ( string Data ) : void

Log data to the developer console. @param Data Anything you want to log to the console.

play ( string EmbeddedSound ) : FlxSound

Creates a new sound object from an embedded Class object. @param EmbeddedSound The sound you want to play. @param Volume How loud to play it (0 to 1). @param Looped Whether or not to loop this sound. @return A FlxSound object.

play ( string EmbeddedSound, float Volume ) : FlxSound
play ( string EmbeddedSound, float Volume, bool Looped ) : FlxSound
playMusic ( string Music ) : void

Set up and play a looping background soundtrack. @param Music The sound file you want to loop in the background. @param Volume How loud the sound should be, from 0 to 1.

playMusic ( string Music, float Volume ) : void
resetInput ( ) : void

Reset the input helper objects (useful when changing screens or states)

Protected Methods

Method Description
changeSounds ( ) : void

An internal function that adjust the volume levels and the music channel after a change.

pauseSounds ( ) : void

Internal helper, pauses all game sounds.

playSounds ( ) : void

Internal helper, pauses all game sounds.

Private Methods

Method Description
destroySounds ( bool ForceDestroy ) : void

Called by FlxGame on state changes to stop and destroy sounds. @param ForceDestroy Kill sounds even if they're flagged survive.

doFollow ( ) : void

Internal function that updates the camera and parallax scrolling.

setGameData ( FlxGame flxGame, int Width, int Height ) : void

Called by FlxGame to set up FlxG during FlxGame's constructor.

unfollow ( ) : void

Stops and resets the camera.

updateSounds ( ) : void

Called by the game loop to make sure the sounds get updated each frame.

Method Details

LoadContent() public static method

public static LoadContent ( GraphicsDevice gd ) : void
gd GraphicsDevice
return void

changeSounds() protected static method

An internal function that adjust the volume levels and the music channel after a change.
protected static changeSounds ( ) : void
return void

follow() public static method

public static follow ( FlxObject Target, float Lerp ) : void
Target FlxObject
Lerp float
return void

followAdjust() public static method

public static followAdjust ( float LeadX, float LeadY ) : void
LeadX float
LeadY float
return void

followBounds() public static method

Specify the boundaries of the level or where the camera is allowed to move. @param MinX The smallest X value of your level (usually 0). @param MinY The smallest Y value of your level (usually 0). @param MaxX The largest X value of your level (usually the level width). @param MaxY The largest Y value of your level (usually the level height). @param UpdateWorldBounds Whether the quad tree's dimensions should be updated to match.
public static followBounds ( int MinX, int MinY, int MaxX, int MaxY ) : void
MinX int
MinY int
MaxX int
MaxY int
return void

followBounds() public static method

public static followBounds ( int MinX, int MinY, int MaxX, int MaxY, bool UpdateWorldBounds ) : void
MinX int
MinY int
MaxX int
MaxY int
UpdateWorldBounds bool
return void

getMuteValue() public static method

Get a number that represents the mute state that we can multiply into a sound transform. @return An unsigned integer - 0 if muted, 1 if not muted.
public static getMuteValue ( ) : int
return int

log() public static method

Log data to the developer console. @param Data Anything you want to log to the console.
public static log ( string Data ) : void
Data string
return void

pauseSounds() protected static method

Internal helper, pauses all game sounds.
protected static pauseSounds ( ) : void
return void

play() public static method

Creates a new sound object from an embedded Class object. @param EmbeddedSound The sound you want to play. @param Volume How loud to play it (0 to 1). @param Looped Whether or not to loop this sound. @return A FlxSound object.
public static play ( string EmbeddedSound ) : FlxSound
EmbeddedSound string
return FlxSound

play() public static method

public static play ( string EmbeddedSound, float Volume ) : FlxSound
EmbeddedSound string
Volume float
return FlxSound

play() public static method

public static play ( string EmbeddedSound, float Volume, bool Looped ) : FlxSound
EmbeddedSound string
Volume float
Looped bool
return FlxSound

playMusic() public static method

Set up and play a looping background soundtrack. @param Music The sound file you want to loop in the background. @param Volume How loud the sound should be, from 0 to 1.
public static playMusic ( string Music ) : void
Music string
return void

playMusic() public static method

public static playMusic ( string Music, float Volume ) : void
Music string
Volume float
return void

playSounds() protected static method

Internal helper, pauses all game sounds.
protected static playSounds ( ) : void
return void

resetInput() public static method

Reset the input helper objects (useful when changing screens or states)
public static resetInput ( ) : void
return void

Property Details

Game public_oe static_oe property

public static Game,Microsoft.Xna.Framework Game
return Microsoft.Xna.Framework.Game

GameTime public_oe static_oe property

public static GameTime,Microsoft.Xna.Framework GameTime
return Microsoft.Xna.Framework.GameTime

LIBRARY_MAJOR_VERSION public_oe static_oe property

Assign a major version to your library. Appears before the decimal in the console.
public static uint LIBRARY_MAJOR_VERSION
return uint

LIBRARY_MINOR_VERSION public_oe static_oe property

Assign a minor version to your library. Appears after the decimal in the console.
public static uint LIBRARY_MINOR_VERSION
return uint

LIBRARY_NAME public_oe static_oe property

If you build and maintain your own version of flixel, you can give it your own name here. Appears in the console.
public static string LIBRARY_NAME
return string

_flxGame protected_oe static_oe property

Internal tracker for game object (so we can pause & unpause)
protected static FlxGame,XnaFlixel _flxGame
return FlxGame

_mute protected_oe static_oe property

Internal flag for whether or not the game is muted.
protected static bool _mute
return bool

_pause protected_oe static_oe property

Internal tracker for game pause state.
protected static bool _pause
return bool

_scrollTarget protected_oe static_oe property

Internal, used to assist camera and scrolling.
protected static Vector2,Microsoft.Xna.Framework _scrollTarget
return Microsoft.Xna.Framework.Vector2

_volume protected_oe static_oe property

Internal volume level, used for global sound control.
protected static float _volume
return float

autoHandlePause public_oe static_oe property

public static bool autoHandlePause
return bool

backColor public_oe static_oe property

public static Color,Microsoft.Xna.Framework backColor
return Microsoft.Xna.Framework.Color

debug public_oe static_oe property

Whether you are running in Debug or Release mode. Set automatically by FlxFactory during startup.
public static bool debug
return bool

elapsed public_oe static_oe property

Represents the amount of time in seconds that passed since last frame.
public static float elapsed
return float

fade public_oe static_oe property

A special effect that fades a color onto the screen. Usage: FlxG.fade.start();
public static FlxFade fade
return FlxFade

flash public_oe static_oe property

A special effect that flashes a color on the screen. Usage: FlxG.flash.start();
public static FlxFlash flash
return FlxFlash

followLead public_oe static_oe property

Used to force the camera to look ahead of the followTarget.
public static Vector2,Microsoft.Xna.Framework followLead
return Microsoft.Xna.Framework.Vector2

followLerp public_oe static_oe property

Used to smoothly track the camera as it follows.
public static float followLerp
return float

followMax public_oe static_oe property

Stores the bottom and right edges of the camera area.
public static Point,Microsoft.Xna.Framework followMax
return Microsoft.Xna.Framework.Point

followMin public_oe static_oe property

Stores the top and left edges of the camera area.
public static Point,Microsoft.Xna.Framework followMin
return Microsoft.Xna.Framework.Point

followTarget public_oe static_oe property

Tells the camera to follow this FlxCore object around.
public static FlxObject followTarget
return FlxObject

gamepads public_oe static_oe property

An array of FlxGamepad objects. Important for input!
public static FlxGamepad,XnaFlixel.data gamepads
return XnaFlixel.data.FlxGamepad

getTimer public_oe static_oe property

public static uint getTimer
return uint

height public_oe static_oe property

The height of the screen in game pixels.
public static int height
return int

keys public_oe static_oe property

A reference to a FlxKeyboard object. Important for input!
public static FlxKeyboard keys
return FlxKeyboard

level public_oe static_oe property

public static int level
return int

levels public_oe static_oe property

FlxG.levels and FlxG.scores are generic global variables that can be used for various cross-state stuff.
public static List levels
return List

maxElapsed public_oe static_oe property

Essentially locks the framerate to a minimum value - any slower and you'll get slowdown instead of frameskip; default is 1/30th of a second.
public static float maxElapsed
return float

mobile public_oe static_oe property

Setting this to true will disable/skip stuff that isn't necessary for mobile platforms like Android (or Windows Phone 7). [BETA]
public static bool mobile
return bool

mouse public_oe static_oe property

A reference to a FlxMouse object. Important for input!
public static FlxMouse mouse
return FlxMouse

music public_oe static_oe property

A handy container for a background music object.
public static FlxSound music
return FlxSound

quake public_oe static_oe property

Reference to the active graphics buffer. Can also be referenced via FlxState.screen. Internal storage system to prevent graphics from being used repeatedly in memory. Access to the Kongregate high scores and achievements API. The support panel (twitter, reddit, stumbleupon, paypal, etc) visor thing A special effect that shakes the screen. Usage: FlxG.quake.start();
public static FlxQuake,XnaFlixel.data quake
return XnaFlixel.data.FlxQuake

save public_oe static_oe property

public static int save
return int

saves public_oe static_oe property

FlxG.saves is a generic bucket for storing FlxSaves so you can access them whenever you want.
public static List saves
return List

score public_oe static_oe property

public static int score
return int

scores public_oe static_oe property

public static List scores
return List

scroll public_oe static_oe property

Stores the basic parallax scrolling values.
public static Vector2,Microsoft.Xna.Framework scroll
return Microsoft.Xna.Framework.Vector2

showBounds public_oe static_oe property

Set showBounds to true to display the bounding boxes of the in-game objects.
public static bool showBounds
return bool

sounds public_oe static_oe property

A list of all the sounds being played in the game.
public static List sounds
return List

timeScale public_oe static_oe property

How fast or slow time should pass in the game; default is 1.0.
public static float timeScale
return float

width public_oe static_oe property

The width of the screen in game pixels.
public static int width
return int