Packagecitrus.view.starlingview
Classpublic class StarlingCamera
InheritanceStarlingCamera Inheritance ACitrusCamera Inheritance Object

The Camera for the StarlingView.



Public Properties
 PropertyDefined By
  allowRotation : Boolean
[override]
StarlingCamera
  allowZoom : Boolean
[override]
StarlingCamera
 InheritedbaseZoom : Number = 1
base zoom - this is the overall zoom factor of the camera
ACitrusCamera
 Inheritedbounds : Rectangle
A rectangle specifying the minimum and maximum area that the camera is allowed to follow the target in.
ACitrusCamera
 InheritedboundsMode : String = BOUNDS_MODE_AABB
how camera movement should be allowed within the defined bounds.
ACitrusCamera
 InheritedcallOnUpdateQueue : Vector.<Object>
[read-only] list of functions/arguments to run in update call for camera sync.
ACitrusCamera
 InheritedcameraLensHeight : Number
The height of the visible game screen.
ACitrusCamera
 InheritedcameraLensWidth : Number
The width of the visible game screen.
ACitrusCamera
 InheritedcamPos : Point
[read-only] the camera center position in state coordinates
ACitrusCamera
 InheritedcamProxy : Object
[read-only] camProxy is read only.
ACitrusCamera
 Inheritedcenter : Point
This defines the camera "center" position as a factor of the camera lens dimensions.
ACitrusCamera
 InheriteddeadZone : Rectangle
defines a zone in the camera space where target will be able to move without the camera following it.
ACitrusCamera
 Inheritedeasing : Point
A value between 0 and 1 that specifies the speed at which the camera catches up to the target.
ACitrusCamera
 Inheritedenabled : Boolean = false
decides wether the camera will be updated by citrus engine.
ACitrusCamera
 InheritedfollowTarget : Boolean = true
ACitrusCamera
 InheritedghostTarget : Point
[read-only] read-only to get the eased position of the target, which is the actual point the camera is looking at ( - the offset )
ACitrusCamera
 InheritedmanualPosition : Point
ACitrusCamera
 InheritedparallaxMode : String = PARALLAX_MODE_TOPLEFT
defines the way parallax is applied to objects position.
ACitrusCamera
 InheritedrotationEasing : Number = 0.05
the ease factor for rotation
ACitrusCamera
 Inheritedtarget : Object
object with x and y properties that will be tracked by the camera
ACitrusCamera
 InheritedtransformMatrix : Matrix
[read-only] This is the transform matrix the camera applies to the state viewroot.
ACitrusCamera
 InheritedzoomEasing : Number = 0.05
the ease factor for zoom
ACitrusCamera
Protected Properties
 PropertyDefined By
 Inherited_aabbData : Object
_aabb holds the axis aligned bounding box of the camera in rect and its relative position to it (with offsetX and offsetY)
ACitrusCamera
 Inherited_allowRotation : Boolean = false
Is the camera allowed to Rotate?
ACitrusCamera
 Inherited_allowZoom : Boolean = false
Is the camera allowed to Zoom?
ACitrusCamera
 Inherited_b : Object
helper object for bounds checking
ACitrusCamera
 Inherited_callOnUpdateQueue : Vector.<Object>
ACitrusCamera
 Inherited_camPos : Point
projected camera position + offset.
ACitrusCamera
 Inherited_camProxy : Object
the _camProxy object is used as a container to hold the data to be applied to the _viewroot.
ACitrusCamera
 Inherited_ce : CitrusEngine
ACitrusCamera
 Inherited_ghostTarget : Point
ghostTarget is the eased position of target.
ACitrusCamera
 Inherited_m : Matrix
helper matrix for transformation
ACitrusCamera
 Inherited_manualPosition : Point
The camera position to be set manually if target is not set.
ACitrusCamera
 Inheritedmzoom : Number
zoom with base factor
ACitrusCamera
 Inheritedoffset : Point
real camera center position
ACitrusCamera
 Inherited_p : Point
helper point
ACitrusCamera
 Inherited_r : Rectangle
helper rectangle
ACitrusCamera
 Inherited_rect : Rectangle
camera rectangle
ACitrusCamera
 Inherited_rotation : Number = 0
the targeted rotation value.
ACitrusCamera
 Inherited_target : Object
The thing that the camera will follow if a manual position is not set.
ACitrusCamera
 Inherited_targetPos : Point
targetPos is used for calculating ghostTarget.
ACitrusCamera
 Inherited_viewRoot : *
ACitrusCamera
 Inherited_zoom : Number = 1
the targeted zoom value.
ACitrusCamera
Public Methods
 MethodDefined By
  
StarlingCamera(viewRoot:Sprite)
StarlingCamera
 Inherited
contains(xa:Number, ya:Number, area:Rectangle = null):Boolean
Check is the given coordinates in State space are contained within the camera.
ACitrusCamera
 Inherited
containsRect(rectangle:Rectangle, area:Rectangle = null):Boolean
Check is the given rectangle is fully contained within the camera.
ACitrusCamera
 Inherited
destroy():void
ACitrusCamera
 Inherited
getRect():Rectangle
returns the camera's axis aligned bounding rectangle in State space.
ACitrusCamera
  
getRotation():Number
[override]
StarlingCamera
  
getZoom():Number
[override]
StarlingCamera
 Inherited
intersectsRect(rectangle:Rectangle, area:Rectangle = null):Boolean
Check is the given rectangle intersects with the camera rectangle.
ACitrusCamera
  
pointFromLocal(x:Number, y:Number, resultPoint:Point = null):Point
equivalent of globalToLocal.
StarlingCamera
  
pointToLocal(p:Point):Point
equivalent of localToGlobal
StarlingCamera
  
renderDebug(sprite:Sprite):void
StarlingCamera
 Inherited
reset():void
sets camera transformation with no easing by setting all easing values to 1 temporarily and updating camera once.
ACitrusCamera
  
Recreates the AABB of the camera.
StarlingCamera
  
rotate(angle:Number):void
[override] rotates the camera by the angle.
StarlingCamera
  
setRotation(angle:Number):void
[override] sets the targeted rotation value to angle.
StarlingCamera
 Inherited
setUp(target:Object, bounds:Rectangle = null, center:Point = null, easing:Point = null):ACitrusCamera
This is a non-critical helper function that allows you to quickly set available camera properties in one place.
ACitrusCamera
  
setZoom(factor:Number):void
[override] sets the targeted zoom value to factor.
StarlingCamera
 Inherited
switchToTarget(newTarget:Object, speed:Number = 10, onComplete:Function = null):void
Moves from the current target to the newTarget at a linear speed, sets the camera's target to be the newTarget then calls onComplete.
ACitrusCamera
 Inherited
tweenSwitchToTarget(newTarget:Object, duration:Number = 2, easingFunction:Function = null, onComplete:Function = null):EazeTween
Moves from current target to newTarget using EazeTween.
ACitrusCamera
  
update():void
[override] Update the camera.
StarlingCamera
  
zoom(factor:Number):void
[override] multiplies the targeted zoom value by factor.
StarlingCamera
  
zoomFit(width:Number, height:Number, storeInBaseZoom:Boolean = false):Number
[override] fits a defined area within the camera lens dimensions.
StarlingCamera
Protected Methods
 MethodDefined By
  
initialize():void
[override] Override this function to change the way camera lens dimensions are calculated or to set other inital properties for the camera type.
StarlingCamera
  
onResize(w:Number, h:Number):void
[override]
StarlingCamera
 Inherited
switchToTargetUpdate(args:Object):Boolean
ACitrusCamera
Public Constants
 ConstantDefined By
 InheritedBOUNDS_MODE_AABB : String = BOUNDS_MODE_AABB
[static] this mode will force the camera (and its 'content') to be contained within the bounds.
ACitrusCamera
 InheritedBOUNDS_MODE_ADVANCED : String = BOUNDS_MODE_ADVANCED
[static] This mode is a mix of the two other modes : The camera offset point is now contained inside inner bounds which allows to never see anything outside of the level like the AABB mode, but unlike the AABB mode, when rotating, the camera doesn't collide with borders as the inner bounds sides are distant from their correspoding bounds sides from the camera's half diagonal length : this means the camera can freely rotate in a circle, and that circle cannot go out of the defined bounds.
ACitrusCamera
 InheritedBOUNDS_MODE_OFFSET : String = BOUNDS_MODE_OFFSET
[static] this mode will force the offset point of the camera to stay within the bounds (whatever the zoom and rotation are) things can be seen outside of the bounds, but there's no zoom recalculation or camera displacement when rotating and colliding with the bounds unlike the other mode.
ACitrusCamera
 InheritedPARALLAX_MODE_DEPTH : String = PARALLAX_MODE_DEPTH
[static] parallaxed objects are 'displaced' according to their parallax value from the center of the camera, giving a perspective/fake depth effect where the vanishing point is the center of the camera.
ACitrusCamera
 InheritedPARALLAX_MODE_TOPLEFT : String = PARALLAX_MODE_TOPLEFT
[static] the parallaxed objects are based on (0,0) of the level.
ACitrusCamera
Property Detail
allowRotationproperty
allowRotation:Boolean[override]


Implementation
    public function get allowRotation():Boolean
    public function set allowRotation(value:Boolean):void
allowZoomproperty 
allowZoom:Boolean[override]


Implementation
    public function get allowZoom():Boolean
    public function set allowZoom(value:Boolean):void
Constructor Detail
StarlingCamera()Constructor
public function StarlingCamera(viewRoot:Sprite)



Parameters
viewRoot:Sprite
Method Detail
getRotation()method
override public function getRotation():Number

Returns
Number
getZoom()method 
override public function getZoom():Number

Returns
Number
initialize()method 
override protected function initialize():void

Override this function to change the way camera lens dimensions are calculated or to set other inital properties for the camera type.

onResize()method 
override protected function onResize(w:Number, h:Number):void

Parameters

w:Number
 
h:Number

pointFromLocal()method 
public function pointFromLocal(x:Number, y:Number, resultPoint:Point = null):Point

equivalent of globalToLocal.

Parameters

x:Number
 
y:Number
 
resultPoint:Point (default = null)

Returns
Point
pointToLocal()method 
public function pointToLocal(p:Point):Point

equivalent of localToGlobal

Parameters

p:Point

Returns
Point
renderDebug()method 
public function renderDebug(sprite:Sprite):void

Parameters

sprite:Sprite — a flash display sprite to render to.

resetAABBData()method 
public function resetAABBData():void

Recreates the AABB of the camera. will use Math.Utils.createAABBData when allowRotation = true.

rotate()method 
override public function rotate(angle:Number):void

rotates the camera by the angle. adds angle to targeted rotation value.

Parameters

angle:Number — in radians.

setRotation()method 
override public function setRotation(angle:Number):void

sets the targeted rotation value to angle.

Parameters

angle:Number — in radians.

setZoom()method 
override public function setZoom(factor:Number):void

sets the targeted zoom value to factor.

Parameters

factor:Number

update()method 
override public function update():void

Update the camera.

zoom()method 
override public function zoom(factor:Number):void

multiplies the targeted zoom value by factor.

Parameters

factor:Number

zoomFit()method 
override public function zoomFit(width:Number, height:Number, storeInBaseZoom:Boolean = false):Number

fits a defined area within the camera lens dimensions. Similar to fitting a rectangle inside another rectangle by multiplying its size, therefore keeping its aspect ratio. the factor used to fit is returned and set as the current target zoom factor. if storeInBaseZoom is set to true, then the calculated ratio is stored in the camera's baseZoom and from now, all zoom will be relative to that ratio (baseZoom is 1 by default and multiplied to every zoom operations you do using the camera methods) - this helps create relative zoom effects while keeping a base zoom when zooming at 1 where the camera would still fit the area you decided : specially usefull for multi resolution handling.

Parameters

width:Number — width of the area to fit inside the camera lens dimensions.
 
height:Number — height of the area to fit inside the camera lens dimensions.
 
storeInBaseZoom:Boolean (default = false) — , whether to store the ratio into baseZoom or not.

Returns
Number — calculated zoom ratio