Skip to content

Anchor

const Anchor: Component

Where Position sits inside the sprite, as a fraction of its size: (0.5, 0.5) is the center, which is also what sprites without it use; (0.5, 1) the bottom center, for characters standing on the ground; (0, 0) the top-left corner, for UI laid out from its corner. Rotation turns the sprite around this point. Flips mirror the image inside its box, so they never move it. Collision helpers (overlaps, hit, entityAt, map.moveAndCollide) and y-sorting use the anchored box. Rapier colliders stay centered on Position.