The
Anchor behavior is useful for automatically positioning objects relative to the window size. This is useful for supporting multiple screen sizes. For more information on features to support multiple screen sizes, see the tutorial
Supporting multiple screen sizes.
The Anchor behavior only has a useful effect when the
Fullscreen in browser project property is set to either
On (crop mode) or
On (scale mode).
Positioning objects relative to the window size
In the top-left of the
Layout View, a dotted outline represents the default size of the game window. Anchored objects should be positioned inside the dotted window area, as shown below.

Now if the window is resized during preview, the objects maintain their relative positions, as shown below:

This is useful for interface elements like notifications and heads-up displays (HUDs).
Relative positioning
The
Left edge and
Right edge position the object relative to the window corners, without changing the object size. For example, if the
Left edge is set to
Window right, the object will always stay the same distance from the
right edge of the window.
The
Right edge and
Bottom edge resize the object relative to the window corners. For example, if you want a Tiled Background to stretch wider as the window widens, set
Right edge to
Window right.
Anchor conditions, actions and expressions
The Anchor object has a single action:
Set enabledSet whether the behavior is enabled or disabled. If disabled, the behavior will not alter the size or position of the object.