/** Creates the health-bar and to display it use the function .build()
but before you can edit the fields */
construct()
let id = this castTo int
main = createFrame(FramehandleTypeNames.backdrop, "Health Bar", WORLD_UI, "", id)
// Create the bar
bar = createFrame(FramehandleTypeNames.backdrop, "Bar", main, "", id)
background = createFrame(FramehandleTypeNames.backdrop, "Background", bar, DEFAULT_BACKGROUND_TEMPLATE, id)
progressBar = createFrame("SIMPLESTATUSBAR", "Progress bar", bar, "", id)
healthText = createFrame(FramehandleTypeNames.text, "Health text", bar, "", id)
healBar = createFrame("SIMPLESTATUSBAR", "Heal bar animation", bar, "", id)
dmgBar = createFrame("SIMPLESTATUSBAR", "Damage bar animation", bar, "", id)
// Create the name text
nameText = createFrame(FramehandleTypeNames.text, "Name text", main, "", id)
// Order the frames
main.setLevel(1)
bar.setLevel(1)
nameText.setLevel(2)
background.setLevel(1)
healBar.setLevel(2)
dmgBar.setLevel(3)
progressBar.setLevel(4)
healthText.setLevel(10)
/** If all the fields are set this functions creates the health-bar*/
function build()
main.setAbsPoint(anchor, pos)
main.setSize(size.x, size.y)
main.setScale(scale)
main.setTexture(EMPTY_BACKGROUND_ROOT, 0, true)
if myUnit != null
currentHealth = myUnit.getHP()
maxHealth = myUnit.getMaxHP()
// Build the progress bar
bar.setPoint(FRAMEPOINT_TOPLEFT, main, FRAMEPOINT_TOP, -0.012, 0.)
bar.setPoint(FRAMEPOINT_BOTTOMRIGHT, main, FRAMEPOINT_BOTTOMRIGHT)
bar.setTexture(EMPTY_BACKGROUND_ROOT, 0, true)
healthText.setText(currentHealth.toString(precision) + " / " + maxHealth.toString(precision))
healthText.setPoint(FRAMEPOINT_TOPLEFT, bar, FRAMEPOINT_TOPLEFT)
healthText.setPoint(FRAMEPOINT_BOTTOMRIGHT, bar, FRAMEPOINT_BOTTOMRIGHT)
healthText.setTextAlignment(TEXT_JUSTIFY_CENTER, TEXT_JUSTIFY_CENTER)
background.setPoint(FRAMEPOINT_TOPLEFT, bar, FRAMEPOINT_TOPLEFT)
background.setPoint(FRAMEPOINT_BOTTOMRIGHT, bar, FRAMEPOINT_BOTTOMRIGHT)
progressBar.setTexture(barTexture, 0, true)
progressBar.setVertexColor(barColor.toInt())
progressBar.setValue(currentHealth/maxHealth * 100.)
progressBar.setPoint(FRAMEPOINT_TOPLEFT, background, FRAMEPOINT_TOPLEFT, 0.006, -0.006)
progressBar.setPoint(FRAMEPOINT_BOTTOMRIGHT, background, FRAMEPOINT_BOTTOMRIGHT, -0.006, 0.006)
healBar.setTexture(barTexture, 0, true)
healBar.setVertexColor(healColor.toInt())
healBar.setPoint(FRAMEPOINT_TOPLEFT, background, FRAMEPOINT_TOPLEFT, 0.006, -0.006)
healBar.setPoint(FRAMEPOINT_BOTTOMRIGHT, background, FRAMEPOINT_BOTTOMRIGHT, -0.006, 0.006)
dmgBar.setTexture(barTexture, 0, true)
dmgBar.setVertexColor(dmgColor.toInt())
dmgBar.setPoint(FRAMEPOINT_TOPLEFT, background, FRAMEPOINT_TOPLEFT, 0.006, -0.006)
dmgBar.setPoint(FRAMEPOINT_BOTTOMRIGHT, background, FRAMEPOINT_BOTTOMRIGHT, -0.006, 0.006)
// Build the name text
nameText.setText(text)
nameText.setPoint(FRAMEPOINT_TOPLEFT, main, FRAMEPOINT_TOPLEFT)
nameText.setPoint(FRAMEPOINT_BOTTOMRIGHT, main, FRAMEPOINT_BOTTOM)
nameText.setTextAlignment(vertAlign, horzAlign)