Class Element
Description
Elements are visual components on layers other than main. They can be manipulated by programming through the Element class at runtime. Used in concert with Layer, this functionality provided a powerful way of controlling the paralax scrolling and other multi-layer game visual effects.
Members
int x
int y
bool show
int imageSet
int imageNo
int id
Element:hide
Hide this element.
Element:move
Move this element to the direction of the given `aim`. This will change the position by eight pixel in one of following direction. These constants cannot be combined.
UP
DOWN
LEFT
RIGHT
Element:moveBy
in int tx
in int ty
out void
Move the element by translation. The new position is the result of `x = x + tx` and `y = y + ty`.
local layer = getLayer( "fw");
for i=1, layer:getSize() do
local t = rand () % 8;
local e = layer:getElement( i - 1);
if (e.y > BUFFERHEI) then
e:moveTo(rand() % BUFFERLEN, (rand() % BUFFERHEI) - BUFFERHEI);
else
if (t == 0) then
e:moveBy(1, 0);
end
if (t == 7) then
e:moveBy(-1, 0);
end
e:moveBy(0, 4);
end
end
Element:moveTo
in int x
in int y
out void
Move this element to a new position.
e:moveTo(100, 100)
Element:setImage
in int imageSet
in int imageNo
out void
Change the image assigned to a given element.
Element:show
Show the element.