cocos2d 绘制虚线

void myDrawNode::drawDottedLine(const Vec2 &origin, const Vec2 &destination, const Color4F &color)

{

       auto _myDrawNode = DrawNode::create();

int averageDis = 20;
int _distance = origin.getDistance(destination);
auto num = (_distance / averageDis);
bool isDottedLine = false;
float Dis_x = (destination.x - origin.x) / num;
float Dis_y = (destination.y - origin.y) / num;
Vec2 averagePos = Vec2(Dis_x, Dis_y);
for (int i = 0; i < num; i++)
{
if (!isDottedLine)
{
_myDrawNode->drawLine(origin + averagePos * i, origin + averagePos* (i + 1), color);
isDottedLine = true;
}
else
{
isDottedLine = false;
}
}

}
阅读更多
上一篇Math
想对作者说点什么? 我来说一句

C# 绘制自定义虚线

2009年04月23日 8KB 下载

没有更多推荐了,返回首页

关闭
关闭