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
Parameters
| Name | Type | Default | Meaning |
|---|---|---|---|
| sprite | Sprite | mySprite | The sprite that the camera will track. |
| offsetx | number | 0 | The horizontal distance in pixels to shift the camera focus from the sprite center (positive moves focus right, negative moves left). |
| offsety | number | 0 | The 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.