Class Layer

Description

Layer are broken into distinct group: background and foreground. The former are displayed behing the main layer, while the later are on top. The Layer allows for direct manipulation of all layers other than main.

Objects on the main layer are sprites and are accessible through the Sprite interface.

Members

  • int id
  • string name
  • int type

Layer:addElement

  • in int ImageSet
  • in int imageNo
  • in int x
  • in int y
  • in bool show*
  • out Element
Create a new Element on this layer. This function returns an Element object.

If show is omited, it is assumed to be false. This causes the element to be invisible by default.

local layer = getLayer( "fw"); 
 
local element = layer:addElement(IMAGES_WHITEBALL_PNG, 0, 100, 100, true); 
 
for i=1, 10 do
 local e = layer:addElement( IMAGES_WHITEBALL_PNG, 0, rand() % BUFFERLEN, (rand() % BUFFERHEI) - BUFFERHEI, true ) ; 
 
end

in parameter show : optional and can be omitted.


Layer:clear

  • in void
  • out void
Clear the layer.

local layer = getLayer( "fw");
layer:clear();

Layer:delete

  • in void
  • out void
Remove this layer. This may invalidate the other layer ids.

Layer:getElement

  • in int index
  • out Element
returns an Element from this layer.

Layer:getSize

  • in void
  • out int size
return the element count for the given layer.

local layer = getLayer( "fw");
Debug:printf("layer size: %d", layer:getSize());

Layer:offsetX

  • in void
  • out int x
Get the x-offset of this layer.

Layer:offsetY

  • in void
  • out int y
Get the y-offset of the layer.

Layer:setOffsetX

  • in int x
  • out void
Set the X-offset a leyer.

Layer:setOffsetY

  • in int y
  • out void
Set the y-offset of the layer.

Layer:setSpeed

  • in int hSpeed
  • in int vSpeed
  • out void
Set the scroll speed of this layer.

Valid values include

SPEED_NOSCROLL,
        SPEED_WHOLE,
        SPEED_1_2,
        SPEED_1_4,
        SPEED_1_8,
        SPEED_1_16,
        SPEED_1_32