CNA Samples

Safe Area

Ported from Microsoft's XNA 4.0 Safe Area.

Source for this sample on GitHub ↗

A cat on a tiled grass background with labels aligned to the four edges of the title-safe area. Play ▸

Opens in a new tab and runs in this browser. Click the canvas first so it receives the keyboard.

About this sample

Safe Area shows how to keep important graphics inside a television's title-safe region. Four labels anchor to the safe area's corners through an aligned SpriteBatch helper rather than assuming that every display exposes its full edge-to-edge image.

Move the cat around the repeating background. The camera begins scrolling before the cat reaches the legal edge, accounting for the sprite's own dimensions and easing its velocity with friction after input stops.

The original sample can add a translucent red safe-area overlay in Xbox Debug builds. Like the original Windows version, this browser build leaves that diagnostic component disabled.

Controls

ActionKeyboardGamepad
Move the catArrow keysLeft stick
ExitEscBack

In the browser, exiting ends the sample rather than closing the tab.