C# Class flxSharp.flxSharp.FlxCamera

The camera class is used to display the game's visuals in the Flash player. By default one camera is created automatically, that is the same size as the Flash player. You can add more cameras or even replace the main camera using utilities in FlxG.
Inheritance: FlxBasic
ファイルを表示 Open project: jlorek/flxSharp Class Usage Examples

Public Properties

Property Type Description
BgColor Color
Bounds FlxRect
Buffer Microsoft.Xna.Framework.Graphics.RenderTarget2D
Deadzone FlxRect
DefaultZoom float
FlashOffsetX float
FlashOffsetY float
FlashSprite FlxObject
Scroll FlxPoint
Target FlxObject
screen FlxSprite
transform Matrix

Protected Properties

Property Type Description
_color Color
_point FlxPoint
_zoom float
fxFadeAlpha float
fxFadeColor Color
fxFadeComplete System.Action
fxFadeDuration float
fxFlashAlpha float
fxFlashColor Color
fxFlashComplete System.Action
fxFlashDuration float
fxShakeComplete System.Action
fxShakeDirection uint
fxShakeDuration float
fxShakeIntensity float
fxShakeOffset FlxPoint

Private Properties

Property Type Description
UpdateHelpers void
drawFX void

Public Methods

Method Description
Fade ( Color color, float duration = 1, System.Action onComplete = null, bool force = false ) : void

The screen is gradually filled with this color.

Fill ( Color color, bool blendAlpha = true ) : void

Fill the camera with the specified color.

Flash ( Color color, float duration = 1, System.Action onComplete = null, bool force = false ) : void

The screen is filled with this color and gradually returns to normal.

FlxCamera ( float x, float y, int width, int height, float zoom ) : System

Instantiates a new camera at the specified location, with the specified size and zoom level.

copyFrom ( FlxCamera camera ) : FlxCamera

Copy the bounds, focus object, and deadzone info from an existing camera.

destroy ( ) : void

Clean up memory.

focusOn ( FlxPoint point ) : void

Move the camera focus to this location instantly.

follow ( FlxObject target, uint style = StyleLockon ) : void

Tells this camera object what FlxObject to track.

getContainerSprite ( ) : object

Fetches a reference to the Flash Sprite object that contains the camera display in the Flash display list. Uses include 3D projection, advanced display list modification, and more. NOTE: We don't recommend modifying this directly unless you are fairly experienced. For simple changes to the camera display, like scaling, rotation, and color tinting, we recommend using the existing FlxCamera variables.

setBounds ( float x, float y, float width, float height, System.Boolean updateWorld = false ) : void

Specify the boundaries of the level or where the camera is allowed to move.

shake ( float intensity = 0.05f, float duration = 0.5f, System.Action onComplete = null, bool force = true, uint direction = ShakeBothAxes ) : void

A simple screen-shake effect.

stopFX ( ) : void

Just turns off all the camera effects instantly.

update ( ) : void

Updates the camera scroll as well as special effects like screen-shake or fades.

Private Methods

Method Description
UpdateHelpers ( ) : void
drawFX ( ) : void

Internal helper function, handles the actual drawing of all the special effects.

Method Details

Fade() public method

The screen is gradually filled with this color.
public Fade ( Color color, float duration = 1, System.Action onComplete = null, bool force = false ) : void
color Color The color you want to use.
duration float How long it takes for the fade to finish.
onComplete System.Action A function you want to run when the fade finishes.
force bool Force the effect to reset.
return void

Fill() public method

Fill the camera with the specified color.
public Fill ( Color color, bool blendAlpha = true ) : void
color Color The color to fill with in 0xAARRGGBB hex format.
blendAlpha bool Whether to blend the alpha value or just wipe the previous contents. Default is true.
return void

Flash() public method

The screen is filled with this color and gradually returns to normal.
public Flash ( Color color, float duration = 1, System.Action onComplete = null, bool force = false ) : void
color Color The color you want to use.
duration float How long it takes for the flash to fade.
onComplete System.Action A function you want to run when the flash finishes.
force bool Force the effect to reset.
return void

FlxCamera() public method

Instantiates a new camera at the specified location, with the specified size and zoom level.
public FlxCamera ( float x, float y, int width, int height, float zoom ) : System
x float X location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.
y float Y location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.
width int The width of the camera display in pixels.
height int The height of the camera display in pixels.
zoom float The initial zoom level of the camera. A zoom level of 2 will make all pixels display at 2x resolution.
return System

copyFrom() public method

Copy the bounds, focus object, and deadzone info from an existing camera.
public copyFrom ( FlxCamera camera ) : FlxCamera
camera FlxCamera The camera you want to copy from.
return FlxCamera

destroy() public method

Clean up memory.
public destroy ( ) : void
return void

focusOn() public method

Move the camera focus to this location instantly.
public focusOn ( FlxPoint point ) : void
point FlxPoint Where you want the camera to focus.
return void

follow() public method

Tells this camera object what FlxObject to track.
public follow ( FlxObject target, uint style = StyleLockon ) : void
target FlxObject The object you want the camera to track. Set to null to not follow anything.
style uint Leverage one of the existing "deadzone" presets. If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling follow().
return void

getContainerSprite() public method

Fetches a reference to the Flash Sprite object that contains the camera display in the Flash display list. Uses include 3D projection, advanced display list modification, and more. NOTE: We don't recommend modifying this directly unless you are fairly experienced. For simple changes to the camera display, like scaling, rotation, and color tinting, we recommend using the existing FlxCamera variables.
public getContainerSprite ( ) : object
return object

setBounds() public method

Specify the boundaries of the level or where the camera is allowed to move.
public setBounds ( float x, float y, float width, float height, System.Boolean updateWorld = false ) : void
x float The smallest X value of your level (usually 0).
y float The smallest Y value of your level (usually 0).
width float The largest X value of your level (usually the level width).
height float The largest Y value of your level (usually the level height).
updateWorld System.Boolean Whether the global quad-tree's dimensions should be updated to match (default: false).
return void

shake() public method

A simple screen-shake effect.
public shake ( float intensity = 0.05f, float duration = 0.5f, System.Action onComplete = null, bool force = true, uint direction = ShakeBothAxes ) : void
intensity float Percentage of screen size representing the maximum distance that the screen can move while shaking.
duration float The length in seconds that the shaking effect should last.
onComplete System.Action A function you want to run when the shake effect finishes.
force bool Force the effect to reset (default = true, unlike flash() and fade()!).
direction uint Whether to shake on both axes, just up and down, or just side to side (use class constants SHAKE_BOTH_AXES, SHAKE_VERTICAL_ONLY, or SHAKE_HORIZONTAL_ONLY).
return void

stopFX() public method

Just turns off all the camera effects instantly.
public stopFX ( ) : void
return void

update() public method

Updates the camera scroll as well as special effects like screen-shake or fades.
public update ( ) : void
return void

Property Details

BgColor public_oe property

The natural background color of the camera. Defaults to FlxG.bgColor. NOTE: can be transparent for crazy FX!
public Color BgColor
return Color

Bounds public_oe property

The edges of the camera's range, i.e. where to stop scrolling. Measured in game pixels and world coordinates.
public FlxRect,flxSharp.flxSharp Bounds
return FlxRect

Buffer public_oe property

The actual bitmap data of the camera display itself.
public RenderTarget2D,Microsoft.Xna.Framework.Graphics Buffer
return Microsoft.Xna.Framework.Graphics.RenderTarget2D

Deadzone public_oe property

You can assign a "dead zone" to the camera in order to better control its movement. The camera will always keep the focus object inside the dead zone, unless it is bumping up against the bounds rectangle's edges. The deadzone's coordinates are measured from the camera's upper left corner in game pixels. For rapid prototyping, you can use the preset deadzones (e.g. STYLE_PLATFORMER) with follow().
public FlxRect,flxSharp.flxSharp Deadzone
return FlxRect

DefaultZoom public_oe static_oe property

While you can alter the zoom of each camera after the fact, this variable determines what value the camera will start at when created.
public static float DefaultZoom
return float

FlashOffsetX public_oe property

public float FlashOffsetX
return float

FlashOffsetY public_oe property

public float FlashOffsetY
return float

FlashSprite public_oe property

public FlxObject,flxSharp.flxSharp FlashSprite
return FlxObject

Scroll public_oe property

Stores the basic parallax scrolling values.
public FlxPoint,flxSharp.flxSharp Scroll
return FlxPoint

Target public_oe property

Tells the camera to follow this FlxObject object around.
public FlxObject,flxSharp.flxSharp Target
return FlxObject

_color protected_oe property

Internal, help with color transforming the flash bitmap.
protected Color _color
return Color

_point protected_oe property

Internal, to help avoid costly allocations.
protected FlxPoint,flxSharp.flxSharp _point
return FlxPoint

_zoom protected_oe property

Indicates how far the camera is zoomed in.
protected float _zoom
return float

fxFadeAlpha protected_oe property

Internal, used to control the "fade" special effect.
protected float fxFadeAlpha
return float

fxFadeColor protected_oe property

Internal, used to control the "fade" special effect.
protected Color fxFadeColor
return Color

fxFadeComplete protected_oe property

Internal, used to control the "fade" special effect.
protected Action,System fxFadeComplete
return System.Action

fxFadeDuration protected_oe property

Internal, used to control the "fade" special effect.
protected float fxFadeDuration
return float

fxFlashAlpha protected_oe property

Internal, used to control the "flash" special effect.
protected float fxFlashAlpha
return float

fxFlashColor protected_oe property

Internal, used to control the "flash" special effect.
protected Color fxFlashColor
return Color

fxFlashComplete protected_oe property

Internal, used to control the "flash" special effect.
protected Action,System fxFlashComplete
return System.Action

fxFlashDuration protected_oe property

Internal, used to control the "flash" special effect.
protected float fxFlashDuration
return float

fxShakeComplete protected_oe property

Internal, used to control the "shake" special effect.
protected Action,System fxShakeComplete
return System.Action

fxShakeDirection protected_oe property

Internal, used to control the "shake" special effect.
protected uint fxShakeDirection
return uint

fxShakeDuration protected_oe property

Internal, used to control the "shake" special effect.
protected float fxShakeDuration
return float

fxShakeIntensity protected_oe property

Internal, used to control the "shake" special effect.
protected float fxShakeIntensity
return float

fxShakeOffset protected_oe property

Internal, used to control the "shake" special effect.
protected FlxPoint,flxSharp.flxSharp fxShakeOffset
return FlxPoint

screen public_oe property

Sometimes it's easier to just work with a FlxSprite than it is to work directly with the BitmapData buffer. This sprite reference will allow you to do exactly that.
public FlxSprite,flxSharp.flxSharp screen
return FlxSprite

transform public_oe property

public Matrix transform
return Matrix