Scratch for Java

Camera()

The camera of a stage: which part of the world the stage shows. Every layer but Layer.UI follows it, the backdrop included; pens draw where the camera shows their position when they draw. Unused, it shows the world as it is: position (0, 0), zoom 100.

Camera camera = this.getStage().getCamera();
camera.setPosition(player.getX(), player.getY());

World coordinates are where sprites are; screen coordinates are where something shows on the stage, with (0, 0) in its centre. The mouse is reported in world coordinates by getMouseX(), so it can be compared with sprite positions directly.

Syntax

Java

new Camera()
Camera()

Create Shareable URL

Select Sections