展开全部
下面是绘制网格的一个方法
/**
* @param raws:行数;
* @param lines:列数;
* @param spaceX:网格水平间距;
* @param spaceY:网格垂直间距;<br />
* 下面是直线样式的相关参数<br />
* @param thickness:直线粗细;
* @param color:直线颜色;
* @param alpha:直线透明度;
**/
private function drawLine(raws:uint = 10, lines:uint = 10, spaceX:Number = 10, spaceY:Number = 15, thickness:Number = 1, color:uint = 0x000000, alpha:Number = 1):Shape
{
var shape:Shape = new Shape();
var h:Number = (raws-1) * spaceY;
var w:Number = (lines - 1) * spaceX;
shape.graphics.lineStyle(thickness, color, alpha);
for(var i:uint = 0; i < raws; i++)
{
shape.graphics.moveTo(0, i * spaceY);
shape.graphics.lineTo(w, i * spaceY);
}
for(var j:uint = 0; j < lines; j++)
{
shape.graphics.moveTo(j * spaceX, 0);
shape.graphics.lineTo(j * spaceX, h);
}
return shape;
}
使用方法,绘制一个15X15、垂直和水平间距都是20的网格,
var shape:Shape = drawLine(15, 15, 20, 20, 2, 0xffff00, 0.8);
addChild(shape);
希望对你有所帮助,不明白的,请追问。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询