Game Development Reference
In-Depth Information
function onDraw ( index, xOff, yOff, xFlip, yFlip )
MOAIGfxDevice.setPenColor(1, 0.64, 0, 1)
MOAIDraw.drawRect(-150,-150,0,-50)
end
scriptDeck = MOAIScriptDeck.new ()
scriptDeck:setRect ( -64, -64, 64, 64 )
scriptDeck:setDrawCallback ( onDraw )
prop = MOAIProp2D.new ()
prop:setDeck ( scriptDeck )
layer:insertProp ( prop )
Drawing Circles
You can use the drawCircle function to draw circles. The syntax is MOAIDraw.drawCircle(xPos,
yPos, radius, steps) , where xPos and yPos are the center of the circle, radius determines the
radius of the circle to be drawn, and the steps determines the granularity , or number of segments
used to draw the circle. A good number for steps is 100.
function onDraw ( index, xOff, yOff, xFlip, yFlip )
MOAIDraw.drawCircle(0, 0, 100, 100)
end
Drawing Filled Circles
You can use the fillCircle function to draw filled circles. The syntax is MOAIDraw.fillCircle(xPos,
yPos, radius, steps) , just like an unfilled circle. The pen color determines the circle fill color.
function onDraw ( index, xOff, yOff, xFlip, yFlip )
MOAIGfxDevice.setPenColor(1, 0.64, 0, 1)
MOAIDraw.fillCircle(0, 0, 100, 100)
end
Drawing Ellipses
To draw ellipses, you can use the function drawEllipse . The syntax is MOAIDraw.drawEllipse(xPos,
yPos, xRadius, yRadius, steps) , where xPos and yPos are the center, xRadius and yRadius
determine the vertical and horizontal radii of the ellipse, and steps determines the granularity.
A good number for steps is 100.
function onDraw ( index, xOff, yOff, xFlip, yFlip )
MOAIDraw.drawEllipse(0, 0, 100, 100)
end
 
Search WWH ::




Custom Search