Members
-
acceleration :Vector
-
Camera acceleration speed.
Type:
-
anchor :Vector
-
Anchor of the camera
Type:
-
container :Container
-
Container that the camera is added to.
Type:
- Container
-
game :Game
-
Reference of the game added to.
Type:
-
isShaking :boolean
-
Whether the camera is currently shaking
Type:
- boolean
-
maxSpeed :number
-
Camera maximum move speed.
Type:
- number
-
maxX :null|number
-
Camera position limit (right)
Type:
- null | number
-
maxY :null|number
-
Camera position limit (down)
Type:
- null | number
-
minX :null|number
-
Camera position limit (left)
Type:
- null | number
-
minY :null|number
-
Camera position limit (up)
Type:
- null | number
-
position :Vector
-
Camera position.
Type:
-
rotation :number
-
Rotation of the camera.
Type:
- number
-
rounding :boolean
-
Use rounding on container position.
Type:
- boolean
-
sensor :Object
-
Sensor box
Type:
- Object
-
speed :Vector
-
Current speed of camera.
Type:
-
target :Sprite
-
The Sprite this camera follows.
Type:
-
threshold :number
-
Type:
- number
-
zoom :Vector
-
Camera zoom.
(2, 2) => 2x
(0.5, 0.5) => 0.5xType:
Methods
-
addTo(game, container)
-
Add camera to container.
Parameters:
Name Type Description game
Game Which game to add to
container
Container Which container to add to
Returns:
This for chaining
- Type
- Camera
-
remove()
-
Remove camera from parent container.
-
setPosition(x, y)
-
Set position of the camera
Parameters:
Name Type Description x
Number X coordinate
y
Number Y coordinate
-
setTarget(target, lerp)
-
Set target of camera.
Parameters:
Name Type Description target
DisplayObject The object to follow
lerp
Boolean Whether lerp to target instead of reseting camera position
-
shake(force, duration, count, forward)
-
Shake camera
Parameters:
Name Type Description force
Vector | Number Max shake distance in pixel
duration
Number How long will the camera shake
count
Number How many times will the camera shake
forward
Boolean ONLY shake forward or not
-
<protected> update(dt, delta)
-
Update method
Parameters:
Name Type Description dt
Number Delta time in millisecond
delta
Number Delta time in second