Label element (used with Interface module)

Description:

This element adds a text label to an interface. The font, size, color, border and background colours can all be customized, before or after adding the label to an interface.

To use:

The code for this element is included in the interface module, linked as follows:

<script language="Javascript" src="gamelib_interface.js"></script>

It's very easy to use this element; you just place it in the interface like so:

  myLabel=new In_Label(10,20,200,50,'Some text!','center','#000000',3,'Arial','#0000ff','#aaaaaa');
  myInterface.add(myLabel);

There are 11 parameters passed to this object. These are:
(1,2) x,y (position relative to interface top left corner)
(3,4) width,height
(5) text for the label,
(6) alignment of the text ('center'|'left'|'right') or if null, it will default to left
(7) color of label text
(8) font size for label (1-7)
(9) font face for label (if null, then Arial,Helvetica,sans-serif is used)
(10) border color (if null, there is no border OR background color)
(11) background color (if null, there is no background or border color)

Any of the properties for a label (excluding position) may be changed at any time.

List of methods for Label

setAlignment
setBackgroundColor
setBorderColor
setFontColor
setFontFace
setFontSize
setText

Descriptions of methods for Label

MethodParametersDescription
setAlignmentString ('left', 'right' or 'center') Sets the horizontal alignment of the label inside its own box (set by the x,y position and width,height dimensions.) This alignment can only be 'left', 'right' or 'center'. If any other value is passed, it will default to 'left'.
setBackgroundColorColor Sets the background color for the label. This will fill the box the label occupies in the interface. Note: The border color must also be set for this to display. If you don't want a border of a different color to the background, just set the border to the same color! If the boolean value false is sent as the parameter to this method, the background color will disappear.
setBorderColorColor Sets the border color for the label. If the parameter passed is the boolean value false, then there will be no border.
setFontColorColor This sets the color of the label text.
setFontFaceString This sets the font face for the label. If the boolean value false is passed as the parameter, then the font will become "Arial,Helvetica,sans-serif" which is an ideal font for a label.
setFontSizeNumeric This sets the size of the font. The range is 1 to 7.
setTextString This sets the text for the label. So you can change a label at any time.