Class Display

Description

Displays are overlays on top of the game screen. These can be scores, lives, points or other messages to be passed on to the player during the game.

default displays are

timeLeft
score
debug
pause

These can be customized using lua scripting.

Members

  • int id

Display:enableShadows

  • in bool toggle
  • out void
Enable the shadow under this display. Only applies to text only. If `toggle` is set to true the shadows are displayed otherwise they're not. You can use other methods to redefine how the shadows are shown.

local display = getDisplayByName("message");
display:enableShadows(true);

Display:expire

  • in int time
  • out void
another alias from Display:setExpireTime()

Display:hide

  • in void
  • out void
Hide this display.

example

local display = getDisplayByName("timeLeft");
display:hide();

Display:move

  • in int x
  • in int y
  • out void
this is another alias from Display:setXY

Display:new

  • in string name
  • in int x
  • in int y
  • in int displayType
  • out Display
Creates a new display elements using ``name``, x, y, and type.

you can use any of the DISPLAY_XXXX constants for ``type``.

DISPLAY_TIME_LEFT
DISPLAY_MESSAGE
DISPLAY_SCORE
DISPLAY_LIVES 
DISPLAY_HP

after adding a new display also remember to set it visible using the show() function.

local display =  Display:new( "petImage", 60, 60, DISPLAY_IMAGE);
   displaySetImage(display.id, IMAGES_ANNIE_OBL  , 0 );
   display.show();

see addDisplay for sample usage.


Display:remove

  • in void
  • out void

Display:setAlpha

  • in int alpha
  • out void

Display:setColor

  • in int r
  • in int g
  • in int b
  • in int a
  • out void
This function changes the color of the text contained in the display.

local score = getDisplayByName("score");
score:setColor(0xff, 0xff, 0xff, 0x80);
score:setFontSize(24);

Display:setContent

  • in void
  • out void
same as setText

Display:setExpireTime

  • in int time
  • out void

Display:setFlagXY

  • in int flagX
  • in int flagY
  • out void
Set the alignment flags for a given Display.

Display:setFont

  • in int fontID
  • out void
Change the fontID used by this Display.

Display:setFontSize

  • in int pxSize
  • out void
Change the font size of a given text display.

local display = getDisplayByName("message");
display:setFontSize(20);

Display:setImage

  • in int imageSet
  • in int imageNo
  • out void
Set the image used by a specific display.

See displaySetImage for more details.


Display:setShadowColor

  • in int red
  • in int green
  • in int blue
  • in int alpha
  • out void
set the color of the shadow under the text in the display. works for text-only display and ony if shadows have been enabled.

display:setShadowColor(255, 32, 32, 255);

Display:setShadowOffset

  • in int tx
  • in int ty
  • out void
changes the relative position of the shadow under the text. works only in text-only display and only if the shadow was enabled (see. enableShadow(...).

display:setShadowOffset(1,1);

Display:setSize

  • in int pxSize
  • out void
This is an alias Display:setFontSize().

display:setSize(40);

Display:setTemplate

  • in string template
  • out void
Change the template used by this Display.

"%.2d"
"%.3d"
"%.8d"

Display:setText

  • in string text
  • out void

Display:setType

  • in int displayType
  • out void

Display:setXY

  • in int x
  • in int y
  • out void
This is just an alias for :move.

Display:show

  • in void
  • out void
Show this display.

example

local display = getDisplayByName("timeLeft");
display:show();

Display:sizeText

  • in string text*
  • out int size
Returns the text size inside a display. The text is optional. If omitted, it will be taken from the display itself.

in parameter text : optional and can be omitted.