Moscrif API Docs for: 2012q3
Show:

Label Class

include "lib://game2d/label.ms";
Library: game2d

Label class is used to show simple text on the screen without support of touch events.

Example:

//label (test)
this.add(new Label({
    text    : "Label text",
    paint   : new Paint(),
    x       : System.width / 2,
    y       : System.height / 2,
}));

Item Index

Methods

Methods

draw

(
  • canvas
)

Draw of the Label. It is usally no need to overwrite this method, but it is possible to overwrite it to customize label appearance.

Parameters:

init

()

Object initialisation. It is usally no need to overwrite this method, but it is possible to overwrite it and use it as a class constructor.

Properties

color

Unknown

Color of the text. The color is in hexadecimal format for four chanels: alpha, red, green and blue. For example:

black       : 0xff000000;
white       : 0xffffffff;
red         : 0xffff0000;
green       : 0xff00ff00;
transparent : 0x00000000;
...

Example:

// label
this.add(new Label({
    text    : "Label text",
    color   : 0xffff0000,
    x       : System.width / 2,
    y       : System.height / 2,
}));

height

Integer

Height of the label. By default it is set acording to the text dimensins

paint

Unknown

Instance of Paint class used to draw text. It specifies font size, color, typeface and also other graphics effects.

Example:

// create an instance of Paint class
var paint = new Paint();
paint.color = 0xff7DFAFF;
paint.textSize = System.width / 20;

// add label into scene
scene.add(new Label({
    text    : "Label text",
    paint   : paint,
    x       : System.width / 2,
    y       : System.height / 2,
}));

text

String

Text on the label.

Example:

this.add(new Label({
    text    : "Label text",
    paint   : new Paint(),
    ...
}));

textSize

Integer

Set size of the font used in the label.

Example:

//label
this.add(new Label({
    text        : "Label text",
    textSize    : 25,
    ...
}));

width

Integer

Width of the label. By default it is set acording to the text dimensins