Phaser API Documentation

setDeadzone([width], [height])


Sets the Camera dead zone.

The deadzone is only used when the camera is following a target.

It defines a rectangular region within which if the target is present, the camera will not scroll. If the target moves outside of this area, the camera will begin scrolling in order to follow it.

The deadzone rectangle is re-positioned every frame so that it is centered on the mid-point of the camera. This allows you to use the object for additional game related checks, such as testing if an object is within it or not via a Rectangle.contains call.

The lerp values that you can set for a follower target also apply when using a deadzone.

Calling this method with no arguments will reset an active deadzone.


name type arguments description
width number <optional>

The width of the deadzone rectangle in pixels. If not specified the deadzone is removed.

height number <optional>

The height of the deadzone rectangle in pixels.


This Camera instance.

Since: 3.11.0
Source: src/cameras/2d/Camera.js (Line 211)