UIScaler Class
The UI scale is responsible for scaling UI components to help easy the burden of different device aspect ratios
Item Index
Methods
- add
- destroy
- fromJSON static
- getScale
- init static
- resize
- resizeBackground static
- resizeBackgrounds static
Properties
- _designedScreen
- _items
- _parent
- ALIGN_BOTTOM static
- ALIGN_CENTER static
- ALIGN_LEFT static
- ALIGN_RIGHT static
- ALIGN_TOP static
- currentScreen static
- initialized static
Methods
add
-
item
-
[vertAlign="center"]
-
[horiAlign="center"]
-
[titleSafe=false]
-
[minScale=1]
-
[maxScale=1]
-
[centeredHorizontally=false]
Manually add an item
Parameters:
-
item
createjs.DisplayObject | PIXI.DisplayObjectThe display object item to add
-
[vertAlign="center"]
String optionalThe vertical align of the item (cefault is center)
-
[horiAlign="center"]
String optionalThe horizontal align of the item (default is center)
-
[titleSafe=false]
Boolean optionalIf the item needs to be in the title safe area (default is false)
-
[minScale=1]
Number optionalThe minimum scale amount (default, scales the same size as the stage)
-
[maxScale=1]
Number optionalThe maximum scale amount (default, scales the same size as the stage)
-
[centeredHorizontally=false]
Boolean optionalMakes sure that the center of the object was at the center of the screen, assuming an origin at the top left of the object
destroy
()
Destroy the scaler object
fromJSON
-
parent
-
jsonSettings
-
jsonItems
-
[immediateDestroy=true]
Create the scaler from JSON data
Parameters:
-
parent
createjs.DisplayObject | PIXI.DisplayObjectThe UI display container
-
jsonSettings
ObjectThe json of the designed settings {designedWidth:800, designedHeight:600, designedPPI:72}
-
jsonItems
ObjectThe json items object where the keys are the name of the property on the parent and the value is an object with keys of "titleSafe", "minScale", "maxScale", "centerHorizontally", "align"
-
[immediateDestroy=true]
Boolean optionalIf we should immediately cleanup the UIScaler after scaling items
Returns:
The scaler object that can be reused
init
-
screenWidth
-
screenHeight
-
screenPPI
Set the current screen settings. If the stage size changes at all, re-call this function
resize
()
Scale the UI items that have been registered to the current screen
resizeBackground
-
The
Scale a single background image according to the UIScaler.width and height
Parameters:
-
The
createjs.Bitmap | PIXI.Bitmapbitmap to scale
resizeBackgrounds
-
bitmaps
Convenience function to scale a collection of backgrounds
Parameters:
-
bitmaps
ArrayThe collection of bitmap images
Properties
_designedScreen
ScreenSettings
private
The screen settings object, contains information about designed size
_parent
createjs.DisplayObject | PIXI.DisplayObject
private
The UI display object to update