Game Development Reference
In-Depth Information
representation of the object. The geometry, or the representation of the object (e.g., a triangle, quad,
or spline) is held in what is called a deck . A deck can hold multiple geometry items, and can also be
called a set .
There are several types of decks to choose from:
MOAIGfxQuad2D : This is a single textured quad.
MOAIGfxQuadDeck2D : This is an array of textured quads (from one texture). This is
similar to what we would refer to as a sprite sheet.
MOAIGfxQuadListDeck2D : This is an array of lists of textured quads (from one
texture). This can be used for advanced sprite sheets.
MOAIMesh : This is a custom vertex buffer object (used for 3D).
MOAIStretchPatch2D : This is a single patch that contains stretchable rows and
columns.
MOAITileDeck2D : This is used for creating a tile map and sprite sheets that are
accessed via an index. The texture is divided into n×m tiles, which are all of the
same size. It can be used for frame animation.
MOAIGfxQuad2D class and load an image to use as the
gfxQuad:setRect(-32,-32, 32, 32)
Once the quad is created, we need to create a prop that will display the quad. We set the rect using
the setRect function or the quad, which is similar to setting the dimensions of the quad:
prop = MOAIProp2D.new()
prop:setDeck(gfxQuad)
prop:setLoc(32,32)
Finally, we need to add this prop to the layer so that it is rendered:
layer:insertProp(prop)
The entire block of is shown following. When we run it, we see the image on the screen.
MOAISim.openWindow ( "test", 320, 480 )
viewport = MOAIViewport.new ()
viewport:setSize ( 320, 480 )
viewport:setScale ( 320, 480 )
layer = MOAILayer2D.new ()
layer:setViewport ( viewport )
MOAISim.pushRenderPass ( layer )
 
Search WWH ::




Custom Search