follow(target, style, lerpX, lerpY)
Tell the camera which sprite to follow.
You can set the follow type and a linear interpolation value.
Use low lerp values (such as 0.1) to automatically smooth the camera motion.
If you find you're getting a slight "jitter" effect when following a Sprite it's probably to do with sub-pixel rendering of the Sprite position.
This can be disabled by setting game.renderer.renderSession.roundPixels = true
to force full pixel rendering.
Parameters
Name | Type | Argument | Default | Description |
---|---|---|---|---|
target | Phaser.Sprite | Phaser.Image | Phaser.Text | The object you want the camera to track. Set to null to not follow anything. | ||
style | number | <optional> | Leverage one of the existing "deadzone" presets. If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling follow(). | |
lerpX | float | <optional> | 1 | A value between 0 and 1. This value specifies the amount of linear interpolation to use when horizontally tracking the target. The closer the value to 1, the faster the camera will track. |
lerpY | float | <optional> | 1 | A value between 0 and 1. This value specifies the amount of linear interpolation to use when vertically tracking the target. The closer the value to 1, the faster the camera will track. |
- Source code: core/Camera.js (Line 269)
Please login to continue.