New feature: Render Layers
Now it's much easier to manage the z-order position when rendering multiple entity outputs. For example:
Now it's much easier to manage the z-order position when rendering multiple entity outputs. For example:
```ruby
world :previous_behavior do
# Automatically rendered in ascending entity ID order (the pre-existing behavior)
entity BackgroundImage
entity Panel
entity Button
entity MouseCursor
# Previously these entities would be rendered to args.outputs,
# now this has changed to args.outputs[:default].
end
# Set a named output target (args.outputs[KEY]) for all instances of an entity class
entity :background_image do
# ...components
layer :background
end
entity :panel do; layer :ui; end
entity :mouse_cursor do; layer :top; end
world :rendering_layers do
entity BackgroundImage
entity Panel
entity Button, layer: { key: :ui } # Same as above, but specific to this entity
entity MouseCursor
# List the layers in the order they should be rendered. Entities of any other layer
# (except for :default) not included in this list will not be rendered.
# Within each layer, entities will be rendered in order of ascending id.
render :background, :ui, :default, :top
# You can omit the `render` line if you only want to render :default
# render :default # (implied)
end
world :using_layer_blocks do
# You can also use a `layer` block to assign a layer to every entity inside
layer :background do
entity BackgroundImage
entity Panel
entity SplashImage
end
# You can declare your layer blocks in any order.
layer :top do; entity MouseCursor; end
layer :ui do; entity Button; end
# Rendered to :default (unless a layer is specified in the entity class)
entity Image
# If you omit :default, it will be added at the end of the list.
render :background, :ui, :top # => [:background, :ui, :top, :default]
end
```