Package | org.flixel |
Class | public class FlxCamera |
Inheritance | FlxCamera FlxBasic Object |
FlxG
.
Property | Defined By | ||
---|---|---|---|
active : Boolean
Controls whether update() is automatically called by FlxState/FlxGroup. | FlxBasic | ||
_ACTIVECOUNT : uint [static] | FlxBasic | ||
alive : Boolean
Useful state for many game objects - "dead" (!alive) vs alive. | FlxBasic | ||
alpha : Number
The alpha value of this camera display (a Number between 0.0 and 1.0). | FlxCamera | ||
angle : Number
The angle of the camera display (in degrees). | FlxCamera | ||
antialiasing : Boolean
Whether the camera display is smooth and filtered, or chunky and pixelated. | FlxCamera | ||
bgColor : uint
The natural background color of the camera. | FlxCamera | ||
bounds : FlxRect
The edges of the camera's range, i.e. | FlxCamera | ||
buffer : BitmapData
The actual bitmap data of the camera display itself. | FlxCamera | ||
cameras : Array
An array of camera objects that this object will use during draw(). | FlxBasic | ||
color : uint
The color tint of the camera display. | FlxCamera | ||
deadzone : FlxRect
You can assign a "dead zone" to the camera in order to better control its movement. | FlxCamera | ||
defaultZoom : Number [static]
While you can alter the zoom of each camera after the fact,
this variable determines what value the camera will start at when created. | FlxCamera | ||
exists : Boolean
Controls whether update() and draw() are automatically called by FlxState/FlxGroup. | FlxBasic | ||
_flashOffsetX : Number
Internal, used to render buffer to screen space. | FlxCamera | ||
_flashOffsetY : Number
Internal, used to render buffer to screen space. | FlxCamera | ||
_flashSprite : Sprite
Internal, used to render buffer to screen space. | FlxCamera | ||
height : uint
How tall the camera display is, in game pixels. | FlxCamera | ||
ID : int
IDs seem like they could be pretty useful, huh?
They're not actually used for anything yet though. | FlxBasic | ||
ignoreDrawDebug : Boolean
Setting this to true will prevent the object from appearing
when the visual debug mode in the debugger overlay is toggled on. | FlxBasic | ||
screen : FlxSprite
Sometimes it's easier to just work with a FlxSprite than it is to work
directly with the BitmapData buffer. | FlxCamera | ||
scroll : FlxPoint
Stores the basic parallax scrolling values. | FlxCamera | ||
target : FlxObject
Tells the camera to follow this FlxObject object around. | FlxCamera | ||
visible : Boolean
Controls whether draw() is automatically called by FlxState/FlxGroup. | FlxBasic | ||
_VISIBLECOUNT : uint [static] | FlxBasic | ||
width : uint
How wide the camera display is, in game pixels. | FlxCamera | ||
x : Number
The X position of this camera's display. | FlxCamera | ||
y : Number
The Y position of this camera's display. | FlxCamera | ||
zoom : Number
The zoom level of this camera. | FlxCamera |
Property | Defined By | ||
---|---|---|---|
_color : uint
Internal, help with color transforming the flash bitmap. | FlxCamera | ||
_fill : BitmapData
Internal helper variable for doing better wipes/fills between renders. | FlxCamera | ||
_flashBitmap : Bitmap
Internal, used to render buffer to screen space. | FlxCamera | ||
_flashPoint : Point
Internal, used to render buffer to screen space. | FlxCamera | ||
_flashRect : Rectangle
Internal, used to render buffer to screen space. | FlxCamera | ||
_fxFadeAlpha : Number
Internal, used to control the "fade" special effect. | FlxCamera | ||
_fxFadeColor : uint
Internal, used to control the "fade" special effect. | FlxCamera | ||
_fxFadeComplete : Function
Internal, used to control the "fade" special effect. | FlxCamera | ||
_fxFadeDuration : Number
Internal, used to control the "fade" special effect. | FlxCamera | ||
_fxFlashAlpha : Number
Internal, used to control the "flash" special effect. | FlxCamera | ||
_fxFlashColor : uint
Internal, used to control the "flash" special effect. | FlxCamera | ||
_fxFlashComplete : Function
Internal, used to control the "flash" special effect. | FlxCamera | ||
_fxFlashDuration : Number
Internal, used to control the "flash" special effect. | FlxCamera | ||
_fxShakeComplete : Function
Internal, used to control the "shake" special effect. | FlxCamera | ||
_fxShakeDirection : uint
Internal, used to control the "shake" special effect. | FlxCamera | ||
_fxShakeDuration : Number
Internal, used to control the "shake" special effect. | FlxCamera | ||
_fxShakeIntensity : Number
Internal, used to control the "shake" special effect. | FlxCamera | ||
_fxShakeOffset : FlxPoint
Internal, used to control the "shake" special effect. | FlxCamera | ||
_point : FlxPoint
Internal, to help avoid costly allocations. | FlxCamera | ||
_zoom : Number
Indicates how far the camera is zoomed in. | FlxCamera |
Method | Defined By | ||
---|---|---|---|
FlxCamera(X:int, Y:int, Width:int, Height:int, Zoom:Number = 0)
Instantiates a new camera at the specified location, with the specified size and zoom level. | FlxCamera | ||
Copy the bounds, focus object, and deadzone info from an existing camera. | FlxCamera | ||
destroy():void [override]
Clean up memory. | FlxCamera | ||
draw():void
Override this function to control how the object is drawn. | FlxBasic | ||
Override this function to draw custom "debug mode" graphics to the
specified camera while the debugger's visual mode is toggled on. | FlxBasic | ||
drawFX():void
Internal helper function, handles the actual drawing of all the special effects. | FlxCamera | ||
fade(Color:uint = 0xff000000, Duration:Number = 1, OnComplete:Function = null, Force:Boolean = false):void
The screen is gradually filled with this color. | FlxCamera | ||
fill(Color:uint = 0, BlendAlpha:Boolean = true):void
Fill the camera with the specified color. | FlxCamera | ||
flash(Color:uint = 0xffffffff, Duration:Number = 1, OnComplete:Function = null, Force:Boolean = false):void
The screen is filled with this color and gradually returns to normal. | FlxCamera | ||
Move the camera focus to this location instantly. | FlxCamera | ||
Tells this camera object what FlxObject to track. | FlxCamera | ||
getContainerSprite():Sprite
Fetches a reference to the Flash Sprite object
that contains the camera display in the Flash display list. | FlxCamera | ||
The scale of the camera object, irrespective of zoom. | FlxCamera | ||
kill():void
Handy function for "killing" game objects. | FlxBasic | ||
postUpdate():void
Post-update is called right after update() on each object in the game loop. | FlxBasic | ||
preUpdate():void
Pre-update is called right before update() on each object in the game loop. | FlxBasic | ||
revive():void
Handy function for bringing game objects "back to life". | FlxBasic | ||
setBounds(X:Number = 0, Y:Number = 0, Width:Number = 0, Height:Number = 0, UpdateWorld:Boolean = false):void
Specify the boundaries of the level or where the camera is allowed to move. | FlxCamera | ||
shake(Intensity:Number = 0.05, Duration:Number = 0.5, OnComplete:Function = null, Force:Boolean = true, Direction:uint):void
A simple screen-shake effect. | FlxCamera | ||
stopFX():void
Just turns off all the camera effects instantly. | FlxCamera | ||
toString():String
Convert object to readable string name. | FlxBasic | ||
update():void [override]
Updates the camera scroll as well as special effects like screen-shake or fades. | FlxCamera |
Constant | Defined By | ||
---|---|---|---|
SHAKE_BOTH_AXES : uint = 0 [static]
Camera "shake" effect preset: shake camera on both the X and Y axes. | FlxCamera | ||
SHAKE_HORIZONTAL_ONLY : uint = 1 [static]
Camera "shake" effect preset: shake camera on the X axis only. | FlxCamera | ||
SHAKE_VERTICAL_ONLY : uint = 2 [static]
Camera "shake" effect preset: shake camera on the Y axis only. | FlxCamera | ||
STYLE_LOCKON : uint = 0 [static]
Camera "follow" style preset: camera has no deadzone, just tracks the focus object directly. | FlxCamera | ||
STYLE_PLATFORMER : uint = 1 [static]
Camera "follow" style preset: camera deadzone is narrow but tall. | FlxCamera | ||
STYLE_TOPDOWN : uint = 2 [static]
Camera "follow" style preset: camera deadzone is a medium-size square around the focus object. | FlxCamera | ||
STYLE_TOPDOWN_TIGHT : uint = 3 [static]
Camera "follow" style preset: camera deadzone is a small square around the focus object. | FlxCamera |
_color | property |
protected var _color:uint
Internal, help with color transforming the flash bitmap.
_fill | property |
protected var _fill:BitmapData
Internal helper variable for doing better wipes/fills between renders.
_flashBitmap | property |
protected var _flashBitmap:Bitmap
Internal, used to render buffer to screen space.
_flashOffsetX | property |
public var _flashOffsetX:Number
Internal, used to render buffer to screen space.
_flashOffsetY | property |
public var _flashOffsetY:Number
Internal, used to render buffer to screen space.
_flashPoint | property |
protected var _flashPoint:Point
Internal, used to render buffer to screen space.
_flashRect | property |
protected var _flashRect:Rectangle
Internal, used to render buffer to screen space.
_flashSprite | property |
public var _flashSprite:Sprite
Internal, used to render buffer to screen space.
_fxFadeAlpha | property |
protected var _fxFadeAlpha:Number
Internal, used to control the "fade" special effect.
_fxFadeColor | property |
protected var _fxFadeColor:uint
Internal, used to control the "fade" special effect.
_fxFadeComplete | property |
protected var _fxFadeComplete:Function
Internal, used to control the "fade" special effect.
_fxFadeDuration | property |
protected var _fxFadeDuration:Number
Internal, used to control the "fade" special effect.
_fxFlashAlpha | property |
protected var _fxFlashAlpha:Number
Internal, used to control the "flash" special effect.
_fxFlashColor | property |
protected var _fxFlashColor:uint
Internal, used to control the "flash" special effect.
_fxFlashComplete | property |
protected var _fxFlashComplete:Function
Internal, used to control the "flash" special effect.
_fxFlashDuration | property |
protected var _fxFlashDuration:Number
Internal, used to control the "flash" special effect.
_fxShakeComplete | property |
protected var _fxShakeComplete:Function
Internal, used to control the "shake" special effect.
_fxShakeDirection | property |
protected var _fxShakeDirection:uint
Internal, used to control the "shake" special effect.
_fxShakeDuration | property |
protected var _fxShakeDuration:Number
Internal, used to control the "shake" special effect.
_fxShakeIntensity | property |
protected var _fxShakeIntensity:Number
Internal, used to control the "shake" special effect.
_fxShakeOffset | property |
protected var _fxShakeOffset:FlxPoint
Internal, used to control the "shake" special effect.
_point | property |
protected var _point:FlxPoint
Internal, to help avoid costly allocations.
_zoom | property |
protected var _zoom:Number
Indicates how far the camera is zoomed in.
alpha | property |
alpha:Number
The alpha value of this camera display (a Number between 0.0 and 1.0).
public function get alpha():Number
public function set alpha(value:Number):void
angle | property |
angle:Number
The angle of the camera display (in degrees). Currently yields weird display results, since cameras aren't nested in an extra display object yet.
public function get angle():Number
public function set angle(value:Number):void
antialiasing | property |
antialiasing:Boolean
Whether the camera display is smooth and filtered, or chunky and pixelated. Default behavior is chunky-style.
public function get antialiasing():Boolean
public function set antialiasing(value:Boolean):void
bgColor | property |
public var bgColor:uint
The natural background color of the camera. Defaults to FlxG.bgColor. NOTE: can be transparent for crazy FX!
bounds | property |
public var bounds:FlxRect
The edges of the camera's range, i.e. where to stop scrolling. Measured in game pixels and world coordinates.
buffer | property |
public var buffer:BitmapData
The actual bitmap data of the camera display itself.
color | property |
color:uint
The color tint of the camera display.
public function get color():uint
public function set color(value:uint):void
deadzone | property |
public var deadzone:FlxRect
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()
.
defaultZoom | property |
public static var defaultZoom:Number
While you can alter the zoom of each camera after the fact, this variable determines what value the camera will start at when created.
height | property |
public var height:uint
How tall the camera display is, in game pixels.
screen | property |
public var screen:FlxSprite
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.
scroll | property |
public var scroll:FlxPoint
Stores the basic parallax scrolling values.
target | property |
public var target:FlxObject
Tells the camera to follow this FlxObject
object around.
width | property |
public var width:uint
How wide the camera display is, in game pixels.
x | property |
public var x:Number
The X position of this camera's display. Zoom does NOT affect this number. Measured in pixels from the left side of the flash window.
y | property |
public var y:Number
The Y position of this camera's display. Zoom does NOT affect this number. Measured in pixels from the top of the flash window.
zoom | property |
zoom:Number
The zoom level of this camera. 1 = 1:1, 2 = 2x zoom, etc.
public function get zoom():Number
public function set zoom(value:Number):void
FlxCamera | () | Constructor |
public function FlxCamera(X:int, Y:int, Width:int, Height:int, Zoom:Number = 0)
Instantiates a new camera at the specified location, with the specified size and zoom level.
ParametersX:int — X location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.
| |
Y:int — 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:Number (default = 0 ) — The initial zoom level of the camera. A zoom level of 2 will make all pixels display at 2x resolution.
|
copyFrom | () | method |
public function copyFrom(Camera:FlxCamera):FlxCamera
Copy the bounds, focus object, and deadzone info from an existing camera.
Parameters
Camera:FlxCamera — The camera you want to copy from.
|
FlxCamera — A reference to this FlxCamera object.
|
destroy | () | method |
override public function destroy():void
Clean up memory.
drawFX | () | method |
public function drawFX():void
Internal helper function, handles the actual drawing of all the special effects.
fade | () | method |
public function fade(Color:uint = 0xff000000, Duration:Number = 1, OnComplete:Function = null, Force:Boolean = false):void
The screen is gradually filled with this color.
Parameters
Color:uint (default = 0xff000000 ) — The color you want to use.
| |
Duration:Number (default = 1 ) — How long it takes for the fade to finish.
| |
OnComplete:Function (default = null ) — A function you want to run when the fade finishes.
| |
Force:Boolean (default = false ) — Force the effect to reset.
|
fill | () | method |
public function fill(Color:uint = 0, BlendAlpha:Boolean = true):void
Fill the camera with the specified color.
Parameters
Color:uint (default = 0 ) — The color to fill with in 0xAARRGGBB hex format.
| |
BlendAlpha:Boolean (default = true ) — Whether to blend the alpha value or just wipe the previous contents. Default is true.
|
flash | () | method |
public function flash(Color:uint = 0xffffffff, Duration:Number = 1, OnComplete:Function = null, Force:Boolean = false):void
The screen is filled with this color and gradually returns to normal.
Parameters
Color:uint (default = 0xffffffff ) — The color you want to use.
| |
Duration:Number (default = 1 ) — How long it takes for the flash to fade.
| |
OnComplete:Function (default = null ) — A function you want to run when the flash finishes.
| |
Force:Boolean (default = false ) — Force the effect to reset.
|
focusOn | () | method |
public function focusOn(Point:FlxPoint):void
Move the camera focus to this location instantly.
Parameters
Point:FlxPoint — Where you want the camera to focus.
|
follow | () | method |
public function follow(Target:FlxObject, Style:uint):void
Tells this camera object what FlxObject
to track.
Parameters
Target:FlxObject — The object you want the camera to track. Set to null to not follow anything.
| |
Style:uint (default = NaN ) — Leverage one of the existing "deadzone" presets. If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling follow() .
|
getContainerSprite | () | method |
public function getContainerSprite():Sprite
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.
Sprite — A Flash Sprite object containing the camera display.
|
getScale | () | method |
public function getScale():FlxPoint
The scale of the camera object, irrespective of zoom. Currently yields weird display results, since cameras aren't nested in an extra display object yet.
ReturnsFlxPoint |
setBounds | () | method |
public function setBounds(X:Number = 0, Y:Number = 0, Width:Number = 0, Height:Number = 0, UpdateWorld:Boolean = false):void
Specify the boundaries of the level or where the camera is allowed to move.
Parameters
X:Number (default = 0 ) — The smallest X value of your level (usually 0).
| |
Y:Number (default = 0 ) — The smallest Y value of your level (usually 0).
| |
Width:Number (default = 0 ) — The largest X value of your level (usually the level width).
| |
Height:Number (default = 0 ) — The largest Y value of your level (usually the level height).
| |
UpdateWorld:Boolean (default = false ) — Whether the global quad-tree's dimensions should be updated to match (default: false).
|
shake | () | method |
public function shake(Intensity:Number = 0.05, Duration:Number = 0.5, OnComplete:Function = null, Force:Boolean = true, Direction:uint):void
A simple screen-shake effect.
Parameters
Intensity:Number (default = 0.05 ) — Percentage of screen size representing the maximum distance that the screen can move while shaking.
| |
Duration:Number (default = 0.5 ) — The length in seconds that the shaking effect should last.
| |
OnComplete:Function (default = null ) — A function you want to run when the shake effect finishes.
| |
Force:Boolean (default = true ) — Force the effect to reset (default = true, unlike flash() and fade()!).
| |
Direction:uint (default = NaN ) — 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).
|
stopFX | () | method |
public function stopFX():void
Just turns off all the camera effects instantly.
update | () | method |
override public function update():void
Updates the camera scroll as well as special effects like screen-shake or fades.
SHAKE_BOTH_AXES | Constant |
public static const SHAKE_BOTH_AXES:uint = 0
Camera "shake" effect preset: shake camera on both the X and Y axes.
SHAKE_HORIZONTAL_ONLY | Constant |
public static const SHAKE_HORIZONTAL_ONLY:uint = 1
Camera "shake" effect preset: shake camera on the X axis only.
SHAKE_VERTICAL_ONLY | Constant |
public static const SHAKE_VERTICAL_ONLY:uint = 2
Camera "shake" effect preset: shake camera on the Y axis only.
STYLE_LOCKON | Constant |
public static const STYLE_LOCKON:uint = 0
Camera "follow" style preset: camera has no deadzone, just tracks the focus object directly.
STYLE_PLATFORMER | Constant |
public static const STYLE_PLATFORMER:uint = 1
Camera "follow" style preset: camera deadzone is narrow but tall.
STYLE_TOPDOWN | Constant |
public static const STYLE_TOPDOWN:uint = 2
Camera "follow" style preset: camera deadzone is a medium-size square around the focus object.
STYLE_TOPDOWN_TIGHT | Constant |
public static const STYLE_TOPDOWN_TIGHT:uint = 3
Camera "follow" style preset: camera deadzone is a small square around the focus object.