Quick Ref - UI Background

A quick reference to the Background Widget & Style.

Widget

Constructor

dUI = require 'dmc_ui'

widget = dUI.newBackground()

widget = dUI.newBackground{
  style = {
    -- style properties here
  }
}

widget = dUI.new9SliceBackground()
widget = dUI.newRectangleBackground()
widget = dUI.newRoundedBackground()

Properties

widget.type = 'rounded'
widget.style
widget.viewStyle

Properties (Style)

widget.debugOn
widget.width
widget.height
widget.anchorX
widget.anchorY

Style

Background Style is a Complex Style in that it has a child 'view', and that child varies depending on the type of background. The following is the basic format for all background Styles.

Constructor

dUI = require 'dmc_ui'

style = dUI.newBackgroundStyle{
  debugOn = false,
  width = 100,
  height = 50,
  anchorX = 0.5,
  anchorY = 1.0,

  type = '<view type>',
  view = {
    -- child style info, see below
  }
}

Child Style Properties

style.view

9-Slice Background

Constructor

dUI = require 'dmc_ui'

style = dUI.newBackgroundStyle{
  debugOn = false,
  width = 100,
  height = 50,
  anchorX = 0.5,
  anchorY = 1.0,

  type = '9-slice',
  view = {
    spriteFrames = {
      topLeft=1,
      topMiddle=2,
      topRight=3,
      middleLeft=4,
      middleMiddle=5,
      middleRight=6,
      bottomLeft=7,
      bottomMiddle=8,
      bottomRight=9,
    },
    offsetLeft=1,
    offsetRight=0,
    offsetTop=0,
    offsetBottom=0,

    sheetInfo=ui_find('theme.default.background.nine_slice-sheet'),
    sheetImage=ui_file('theme/default/background/nice_slice-sheet.jpg'),
  }
}

Rectangle Background

Constructor

dUI = require 'dmc_ui'

style = dUI.newBackgroundStyle{
  debugOn = false,
  width = 100,
  height = 50,
  anchorX = 0.5,
  anchorY = 1.0,

  type = 'rectangle',
  view = {
    fillColor={1,1,1,1},
    strokeColor={0.1,0.1,0.1,1},
    strokeWidth=2
  }
}

Rounded Background

Constructor

dUI = require 'dmc_ui'

style = dUI.newBackgroundStyle{
  debugOn = false,
  width = 100,
  height = 50,
  anchorX = 0.5,
  anchorY = 1.0,

  type = 'rounded',
  view = {
    cornerRadius=3,
    fillColor={1,1,1,1},
    strokeColor={1,0,1,1},
    strokeWidth=1
  }
}