Set some important variables for other classes to use, based on the size and orientation of the viewport
- License
- GPL-3.0-only
Methods
(static) getAlignedPos(_alignmentH, _alignmentV, _itemWidth, _itemHeight, _offsetHopt, _offsetVopt) → {object}
Based on a desired alignment and size of an item, calculate its coordinates
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
_alignmentH |
HORIZ_ALIGN | Horizontal alignment |
|
_alignmentV |
VERT_ALIGN | Vertical alignment |
|
_itemWidth |
number | The height of the item |
|
_itemHeight |
number | The width of the item |
|
_offsetH |
number |
optional |
A horizontal offset to be applied after the basic calculation |
_offsetV |
number |
optional |
A vertical offset to be applied after the basic calculation |
Returns
object |
x/y coordinates for the item |
(static) getRectangle(_type) → {object}
Based on current layout/dimensions, get a rectangle describing the position and size of a specific object (eg gameplay area, title image, sound icon)
Parameters
Name | Type | Description |
---|---|---|
_type |
RECTANGLE | Which rectangle do we want? |
Returns
object |
A rectangle with |
(static) init()
Simple initialisation
This just calls the update function with a default gameplay area size so that the caclulations have something to work with
(static) setProportionalSizes()
Calculate some values which are used heavily throughout the app
Layout.proportionalMultiplier
- Used to shrink/grow things in relation to an ideal (GAME.SCALING_TARGET_SIZE
), to try to make things feel consistent between highly variable screen sizesLayout.mainPaddingProportional
- Common padding used eg between text/icons and the edge of the screenLayout.textBgPaddingProportional
- Extra spacing around text and the borders of its backgroundLayout.hitAreaPaddingProportional
- Invisible spacing around tappable items (eg icons) to make them easier to hit
(static) update(_data)
Calculate sizes (particularly recctangles) for lots of important parts of the game and UI
Parameters
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
_data |
object |
|