A layer is like a transparent sheet of glass that objects are painted on to. Layers can be used to show different groups of objects in front or behind each other, like the foreground and background. Layers belong to a layout and can be added, edited and removed in the Layers Bar. Layers can be scrolled at different rates for parallax effects, and also individually scaled and rotated, which makes them a powerful way to make interesting visual effects in games.
Layers are also important to add non-scrolling interfaces (or HUDs or UIs) to scrolling games. A layer with its parallax set to 0, 0 will not scroll at all, so any objects placed on this layer will always stay in the same place on-screen.
A common arrangement for layers might be:
HUD (top layer - health bar, UI info etc.)
Foreground (main game objects)
Middleground (a parallaxing background layer)
Background (bottom layer - the background)
Layers can also have effects applied, which affects all content appearing on the layer.
Sometimes many layouts in a project have the same content on a particular layer, such as for interface or HUD overlaid on to the game. Changing this content then becomes a chore since changes must be repeated on every layout. Global layers are aimed at solving this problem.
If a layer's Global property is set to Yes, then every layer in the project with the same name is overridden by that layer. The initial objects, as well as its properties, are used instead of the other layer's own content and properties. Then changes can be made once to the original global layer, and the changes will be applied project-wide.
The layer with the Global property set to Yes is where all changes must be made from. On other layers in the project with the same name, the Global property will be read-only and display (yes, overridden) to indicate it is being substituted by a different layer. It will also not display in the layout view on other layouts, although its contents will appear when previewing the project.
The properties for a layer can be edited in the Properties Bar after clicking the layer in the Layers Bar. Note this also changes the active layer - see the active layer property in Layout properties for more information.
- The name of the layer, which can be used to refer to the layer in the event system.
- Initial visibility
- Whether or not the layer is initially visible when previewing . This is different to the Visible in editor property which only affects the Layout View.
- Background color
- The background color for the layer. It is ignored if Transparent is Yes.
- Ignore background color and make the layer have a transparent background.
- Set the opacity (or semitransparency) of the layer, from 0 (invisible) to 100 (opaque).
- Force own texture
- Force the layer to always render to an intermediate texture rather than directly to the screen. This is useful for some kinds of effects. However, it slows down rendering, so it should be set to No unless specifically needed.
- Use render cells
- Optimise the rendering of this layer for extremely large layouts with a large number of static objects spread out across this layer. This is not normally necessary except for certain types of large game. If this is used incorrectly, it can actually make rendering less efficient, so make sure you can measure a performance improvement before using it. For more information, see the blog post How render cells work.
- Scale rate
- Change the rate at which the layer zooms if scaling is applied to the layer or layout, a bit like parallax but for zoom. A scale rate of 0 means the layer will always stay at 100% scale regardless of the scaling applied. A scale rate of 100 means it will scale normally.
- Change the rate at which the layer scrolls in the horizontal and vertical directions. A parallax rate of 100, 100 means ordinary scrolling, 0, 0 means it will never scroll (useful for UIs), 50, 50 means scrolling half as fast, etc. Also useful for multi-layer parallaxing backgrounds.
- See the section above on Global layers. If Yes, it will override every other layer in the project with the same name with its own contents and properties. Overridden layers display this property read-only as (yes, overridden). If No its contents and properties are unique to itself.
- Visible in editor
- Whether or not the layer is showing in the Layout View . Note this is different to the Initial visibility property which only affects previewing. This setting can also be accessed via the Layers Bar.
- Whether or not the layer is locked in the Layout View. Objects on locked layers cannot be selected. This setting can also be accessed via the Layers Bar.
- Parallax in editor
- If enabled, the parallax properties will also be applied to the Layout View, allowing you to preview what the effect will look like.