shake(intensity, duration, force, direction, shakeBounds) → {boolean}
This creates a camera shake effect. It works by applying a random amount of additional
spacing on the x and y axis each frame. You can control the intensity and duration
of the effect, and if it should effect both axis or just one.
When the shake effect ends the signal Camera.onShakeComplete is dispatched.
Parameters
Name | Type | Argument | Default | Description |
---|---|---|---|---|
intensity | float | <optional> | 0.05 | The intensity of the camera shake. Given as a percentage of the camera size representing the maximum distance that the camera can move while shaking. |
duration | number | <optional> | 500 | The duration of the shake effect in milliseconds. |
force | boolean | <optional> | true | If a camera shake effect is already running and force is true it will replace the previous effect, resetting the duration. |
direction | number | <optional> | Phaser.Camera.SHAKE_BOTH | The directions in which the camera can shake. Either Phaser.Camera.SHAKE_BOTH, Phaser.Camera.SHAKE_HORIZONTAL or Phaser.Camera.SHAKE_VERTICAL. |
shakeBounds | boolean | <optional> | true | Is the effect allowed to shake the camera beyond its bounds (if set?). |
Returns
True if the shake effect was started, otherwise false.
- Source code: core/Camera.js (Line 358)
Please login to continue.