Cocos2d-x 3.x图元绘制

来源:互联网 发布:pycharm tensorflow 编辑:程序博客网 时间:2024/05/16 20:24

cocos2d提供了绘制点、线段和多边形等等基本图元的功能。

简介

在3.x版本中,DrawNode是用于绘制基本图元的类。由于它使用了”批处理”(Batch draw),因此它绘制点、线段、多边形都要比DrawPrimitives快。

基本API

void drawPoint (const Vec2 &point, const float pointSize, const Color4F &color);//画一个点void drawPoints (const Vec2 *position, unsigned int numberOfPoints, const Color4F &color);//画一组点void drawPoints (const Vec2 *position, unsigned int numberOfPoints, const float pointSize, const Color4F &color);//画一组点
  • 线
void drawLine (const Vec2 &origin, const Vec2 &destination, const Color4F &color);//使用指定颜色画一条从起始点到目的地点的线
  • 矩形
void drawRect (const Vec2 &origin, const Vec2 &destination, const Color4F &color);//左上角和右下角坐标
  • 多边形
void drawPoly (const Vec2 *poli, unsigned int numberOfPoints, bool closePolygon, const Color4F &color);// poli : 多边形的各个顶点// numberOfPoints :顶点个数// closePolygon :是否闭合
  • 设置颜色混合器
void setBlendFunc (const BlendFunc &blendFunc);//设置颜色混合模式。
  • 获取当前设定的线宽
float getLineWidth ()
  • 创建时可以指定默认线宽
static DrawNode *   create (int defaultLineWidth=DEFAULT_LINE_WIDTH)
0 0
原创粉丝点击