Game Development Reference
In-Depth Information
Animating Text
The
MOAITextBox
has a
spool
function, which allows for the text to be revealed character by
character. This provides for some interesting effects when displaying text.
textbox:spool()
Drawing Vector Primitives
Moai uses the class
MOAIDeck
to create a canvas on which drawing operations can be performed. All
drawing is performed in the local space of the deck.
MOAIScriptDeck
type, as follows:
scriptDeck
object relies on a callback function to manage the drawing of the
scriptDeck
, which
setDrawCallback
function. The callback has the parameters
index
,
xOffset
,
,
xScale
, and
yScale
. The
index
determines the deck that needs to be redrawn, and the
The MOAI drawing classes allow for drawing all of the following:
Lines
Rectangles
Filled rectangles
Circles
Filled circles
Ellipses
Filled ellipses
Polygons
Points
Drawing attributes
Drawing Lines
A single line can be drawn using the
drawRay
function, the syntax for which is
MOAIDraw.drawRay(x, y, dx, dy)
. The
x
and
y
are the absolute coordinates, and the
dx
and
dy
are the directions of the line extending from the
x
and
y
coordinates.