MakeCode Games!

A fan-made community library of MakeCode Arcade games. Visit MakeCode Arcade to make a game!

← Back to extensions

Camera Offset

Customize how the camera follows sprites in MakeCode Arcade by adding horizontal and vertical offsets.

camera follow sprite with offset x offset y

Problem it solves

You want the camera to follow your player, but you want them positioned off-center so players can see further ahead in a platformer or racing game.

What this block does

Makes the game camera follow a sprite while applying a horizontal (X) and vertical (Y) pixel offset instead of locking directly to the center of the screen.

The block

Block ID: riknoll_camera_follow_with_offset

camera follow sprite $sprite with offset x $offsetx offset y $offsety block

Parameters

NameTypeDefaultMeaning
spriteSpritemySpriteThe sprite that the camera will track.
offsetxnumber0The horizontal distance in pixels to shift the camera focus from the sprite center (positive moves focus right, negative moves left).
offsetynumber0The vertical distance in pixels to shift the camera focus from the sprite center (positive moves focus down, negative moves up).

Example

let mySprite = sprites.create(img`.`, SpriteKind.Player)
controller.moveSprite(mySprite)
cameraOffsetScene.cameraFollowWithOffset(mySprite, 20, 0)

Add the extension

Add github:riknoll/arcade-camera-offset to your project, or open: Import arcade-camera-offset.