Game Development Reference
In-Depth Information
Drawing Rectangles
The easiest way to draw a rectangle is to use the syntax MOAIDraw.drawRect(x1, y1, x2, y2) . It
takes four parameters: the x and y coordinates where the rectangle starts and the endpoints that
enclose the rectangle. The code below draws a rectangle on the screen as seen in Figure 10-3 .
Figure 10-3. Drawing a rectangle with a stroke (border)
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 )
function onDraw ( index, xOff, yOff, xFlip, yFlip )
MOAIDraw.drawRect(-150,-150,0,-50)
end
scriptDeck = MOAIScriptDeck.new ()
scriptDeck:setRect (-64, -64, 64, 64 )
scriptDeck:setDrawCallback ( onDraw )
 
Search WWH ::




Custom Search