springroll.ScaleManager Class

Module: UI

The UI scale is responsible for scaling UI components to help easy the burden of different device aspect ratios. The UI can expand either vertically or horizontally to fill excess space.

Constructor

springroll.ScaleManager

(
  • [options]
)

Parameters:

  • [options] Object optional

    The options

    • [size] Object optional

      The dimensions of the Scaler

      • [width] Number optional
        The designed width
      • [height] Number optional
        The designed height
      • [maxwidth=size.width] Number optional
        The designed max width
      • [maxheight=size.height] Number optional
        The designed max height
    • [items] Object optional

      The items to load

    • [container] PIXI.DisplayObjectContainer | createjs.Container optional

      The container if adding items

    • [display] Object optional

      The current display

    • [enabled=false] Boolean optional

      If the scaler is enabled

_getAdapter

(
  • display
)
private

Defined in _getAdapter:168

Get the adapter by display

Parameters:

  • display Object

    The canvas renderer display

_resize

(
  • w
  • h
)
private

Defined in _resize:565

Scale the UI items that have been registered to the current screen

Parameters:

  • w Number

    The current width of the application

  • h Number

    The current height of the application

addBackground

()
deprecated

Defined in addBackground:14

Deprecated: since version 0.4.0

See addItem

addItem

(
  • bitmap
  • settings
)
springroll.ScaleManager

Defined in addItem:483

Add a bitmap to make be fullscreen

Parameters:

  • bitmap PIXI.Sprite | createjs.Bitmap

    The bitmap to scale

  • settings String

    Must be 'cover-image'

Returns:

springroll.ScaleManager:

The instance of this ScaleManager for chaining

addItem

(
  • displayObject
  • [settings="center"]
)
springroll.ScaleManager

Defined in addItem:449

Manually add an item

Parameters:

  • displayObject createjs.DisplayObject | PIXI.DisplayObject

    The display object item

  • [settings="center"] Object | String optional

    The collection of settings or the align property

    • [align="center"] String optional

      The vertical alignment ("top", "bottom", "center") then horizontal alignment ("left", "right" and "center"). Or you can use the short- handed versions: "center" = "center-center", "top" = "top-center", "bottom" = "bottom-center", "left" = "center-left", "right" = "center-right".

    • [titleSafe=false] Boolean | String optional

      If the item needs to be in the title safe area. Acceptable values are false, "horizontal", "vertical", "all", and true. The default is false, and true is the same as "all".

    • [minScale=NaN] Number optional

      The minimum scale amount (default, scales the same size as the stage)

    • [maxScale=NaN] Number optional

      The maximum scale amount (default, scales the same size as the stage)

    • [centeredHorizontally=false] Boolean optional

      Makes sure that the center of the object is directly in the center of the stage assuming origin point is in the upper-left corner.

    • [x] Number optional

      The initial X position of the item

    • [y] Number optional

      The initial Y position of the item

    • [scale] Object optional

      The initial scale

      • [x] Number optional
        The initial scale X value
      • [y] Number optional
        The initial scale Y value
    • [pivot] Object optional

      The pivot point

      • [x] Number optional
        The pivot point X location
      • [y] Number optional
        The pivot point Y location
    • [rotation] Number optional

      The initial rotation in degrees

    • [hitArea] Object | Array optional

      An object which describes the hit area of the item or an array of points.

      • [type] String optional
        If the hitArea is an object, the type of hit area, "rect", "ellipse", "circle", etc

Returns:

springroll.ScaleManager:

The instance of this ScaleManager for chaining

addItems

(
  • parent
  • items
)
springroll.ScaleManager

Defined in addItems:413

Register a dictionary of items to the ScaleManager to control.

Parameters:

  • parent

    The parent object that contains the items as variables.

  • items Object

    The 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", see ScaleManager.addItem for a description of the different keys.

Returns:

springroll.ScaleManager:

The instance of this ScaleManager for chaining

destroy

()

Defined in destroy:599

Destroy the scaler object

removeBackground

()
deprecated

Defined in removeBackground:26

Deprecated: since version 0.4.0

removeItem

(
  • display
)
springroll.ScaleManager

Defined in removeItem:393

Remove a single item from the scaler

Parameters:

  • display createjs.Bitmap | PIXI.Sprite | createjs.Container | PIXI.DisplayObjectContainer

    The object to remove

Returns:

springroll.ScaleManager:

The ScaleManager for chaining

removeItems

(
  • parent
  • items
)
springroll.ScaleManager

Defined in removeItems:327

Remove all items where the item display is a the container or it contains items

Parameters:

  • parent

    The object which contains the items as live variables.

  • items Object

    The items that was passed to addItems

Returns:

springroll.ScaleManager:

The ScaleManager for chaining

removeItemsByParent

(
  • container
)
springroll.ScaleManager

Remove all items where the item display is a child of the container display

Parameters:

  • container createjs.Container | PIXI.DisplayObjectContainer

    The container to remove items from

Returns:

springroll.ScaleManager:

The ScaleManager for chaining

_adapter

Object private

Defined in _adapter:69

The adapter for universal scale, rotation size access

_enabled

Boolean private

Defined in _enabled:76

The internal enabled

_items

Array private

Defined in _items:47

The configuration for each items

_scale

Number private

Defined in _scale:61

The current overall scale of the game

Default: 1

_size

Object private

Defined in _size:54

The screen settings object, contains information about designed size

ALIGN_BOTTOM

String final static

Defined in ALIGN_BOTTOM:128

Vertically align to the bottom

Default: "bottom"

ALIGN_CENTER

String final static

Defined in ALIGN_CENTER:158

Vertically or horizontally align to the center

Default: "center"

ALIGN_LEFT

String final static

Defined in ALIGN_LEFT:138

Horizontally align to the left

Default: "left"

ALIGN_RIGHT

String final static

Defined in ALIGN_RIGHT:148

Horizontally align to the right

Default: "right"

ALIGN_TOP

String final static

Defined in ALIGN_TOP:118

Vertically align to the top

Default: "top"

display

springroll.AbstractDisplay

Defined in display:198

Set the display

enabled

Boolean

Defined in enabled:299

Whether the ScaleManager should listen to the stage resize. Setting to true initialized a resize.

Default: true

numItems

Number

Defined in numItems:286

The total number of items

scale

Number

Defined in scale:273

Get the current scale of the screen relative to the designed screen size

size

Object

Defined in size:210

The design sized of the application

Default: null

size.height

Number

Defined in size.height:219

The designed width of the application

size.maxHeight

Number

Defined in size.maxHeight:228

The designed maxHeight of the application

Default: size.height

size.maxWidth

Number

Defined in size.maxWidth:223

The designed max width of the application

Default: size.width

size.width

Number

Defined in size.width:215

The designed width of the application

verbose

Boolean

Defined in verbose:85

If we should log verbose messages (unminified module only!)

Default: false