The camera class.
It is in charge of repositioning and rescaling its associated nb.Scene
instance
and all the objects that were added to the camera using the add
(not addChild
) function.
You usually shouldn't manipulate an nb.Scene
's properties directly, do it using its
associated camera instead.
0.1.0
.Constructor
Variables
Methods
add(o:Object, pos:Int = 0, persistent:Bool = false, autoReposition:Bool = true, autoRescale:Bool = true):ObjData
Adds an object on the camera.
It adds the tag "OnCam" to it which means the object is managed by the camera.
Parameters:
o | An |
---|---|
pos |
|
persistent | If |
autoReposition | Whether the camera is allowed to reposition the object. |
autoRescale | Whether the camera is allowed to rescale the object. |
Returns:
An nb.Camera.ObjData
containing the aforementioned informations.
inlineaddOnMoveF(f:Float ‑> Void, name:String = "_"):Void
Stores a function that gets executed whenever the cam moves the associated scene.
inlineaddOnScaleF(f:Float ‑> Void, name:String = "_"):Void
Stores a function that gets executed whenever the cam rescales the associated scene.
reAdd(o:Object, data:ObjData):Void
Same as the add
function but uses saved nb.Camera.ObjData
.
Used on camera switch.
Parameters:
o | An |
---|---|
data |
|
setBounds(xMin:Float, xMax:Float, yMin:Float, yMax:Float):Void
The area the camera can move to is limited by these values. Sets bounds
.
setZoom(zoom:Float, ?anchor:Point, now:Bool = false):Void
Set the camera zoom value
Parameters:
zoom | Zoom value. 1 is 100%, 2 is 200%, 0.5 is 50%... |
---|---|
anchor | If not |
now | Whether the rescaling should happen immediately. |
update(dt:Float):Void
Updates it's associated scene's and managed objects' properties.
It is called every frame by its associated scene's mandatoryUpdate
function,
which happens at the end of the game loop.
Also called by some of this instance's functions when requested.
Parameters:
dt | Elapsed time in seconds. |
---|