-
Notifications
You must be signed in to change notification settings - Fork 0
HudElement class
Dome Keeper features a dedicated class for managing HUD elements, known as HudElement
. This class encompasses three key properties: size
, layoutPriority
, and layoutWeight
.
The size
property specifies the dimensions of the HUD element relative to a 6-pixel grid. Expressed in Vector2, each component signifies the number of grid units. For instance, an element with an actual size of 18x18 pixels would have a size
property of Vector2(3, 3)
, considering 18 divided by 6 equals 3.
The layoutPriority
property establishes the order in which HUD elements are arranged relative to one another. Lower priority elements are positioned before higher priority ones. If an element has a priority of 5, it will be placed before an element with a priority of 6.
The layoutWeight
property sets an element's preferred location within the HUD grid.
Assigning different values to layoutWeight
allows you to affect the positioning behavior of elements. When all elements share the same weight (e.g., (1, 1)), they will form a triangle in the screen's corner, provided they are small enough.
However, an element with higher weight in one dimension (e.g., (10, 1)) incurs a higher "cost" to move further in that direction. Therefore, the system aims to minimize this cost, placing the element close to the corner. For instance, an element with a layoutWeight
of (10, 1) is likely to be placed near the left screen edge, stacked upwards.
By manipulating these properties, you can easily govern the size, sequence, and positioning of HUD elements.
Is the following image those concepts are illustrated:
Most HUD elements in Dome Keeper adopt colors via the game's palette swap or Style system. You can find more information about this system here.