Phaser API Documentation

  Version: 
setViewport(x, y, width, [height])

Description:

This method sets the position and size of the Camera viewport in a single call.

If you're trying to change where the Camera is looking at in your game, then see the method Camera.setScroll instead. This method is for changing the viewport itself, not what the camera can see.

By default a Camera is the same size as the game, but can be made smaller via this method, allowing you to create mini-cam style effects by creating and positioning a smaller Camera viewport within your game.

Parameters:

name type arguments Default description
x number

The top-left x coordinate of the Camera viewport.

y number

The top-left y coordinate of the Camera viewport.

width number

The width of the Camera viewport.

height number <optional> width

The height of the Camera viewport.

Returns:
Description:

This Camera instance.

Since: 3.0.0