Graphic.TrackingCamera Class
the TrackingCamera is a Camera which can follow a target.
When the target near the edges of the camera, the camera move for always keep the target in the field of view.
This behaviour can be enabled or disabled whith lock
.
The margin
property provides a way to configure the motion field of the player.
If we set the margin.x to 10, the camera don't let the player to approach whitin 10px.
Constructor
Graphic.TrackingCamera
-
target
Parameters:
-
target
GraphicObject
Item Index
Methods
_updateMatrix
()
protected
Update the matrix after a transformation.
draw
()
Update the camera position. If locked and the target go out of camera, the camera follow the target.
prepare
-
context
prepare is called before each draw on the canvas. The canvas 2D context must be completely reset.
By default, context matrix are multiplied by internal matrix. save and restore operations are done by the caller.
Parameters:
-
context
CanvasRenderingContext2DThe canvas context which will be used to draw.
rotate
-
angle
Apply a rotation to the camera.
Parameters:
-
angle
Numberrotation angle in degrees.
Returns:
scale
-
x
-
y
Apply a scale transformation to the camera.
Parameters:
-
x
Number -
y
Number
Returns:
skew
-
a
-
b
Apply a skew transformation to the camera.
Parameters:
-
a
Number -
b
Number
Returns:
translate
-
x
-
y
Apply a translation to the camera.
Parameters:
-
x
Object -
y
Object
Returns:
Properties
locked
Boolean
Lock or not the camera on the target.
Default: true
margin
Object
inner screen margin
Sub-properties:
-
x
Number -
y
Number
matrix
Matrix2D
matrix used for define the view.
Note that modify it don't automatically refresh the associated layer. You should refresh the Layer after this operation.
Directly modifing the matrix is not compatible with other matrix Camera's method (translate
, rotate
,
skew
or scale
).
Calling one of these method will recreate the matrix and erasing your matrix.
For applying transformations, you should modify directly the matrix.
target
GraphicObject
target pointed by the camera