1.drawaDot draw a dot, official explanation
void |
Drawdot (const VEC2 &pos, float radius, const color4f &color) |
|
The point at which the predetermined position is drawn, given the radius and color |
Instance:
[CPP]View Plaincopy
- Auto r= cocos2d::D rawnode::create ();
- AddChild (R);
- R->drawdot (VEC2 (100,100), 10,color4f::green);
Effect:
A green dot with a radius of 10 is plotted on coordinate 100,100
2.drawSegment draw a line, official explanation
void |
Drawsegment (const VEC2 &from, const VEC2 &to, float radius, const color4f &color) |
|
Draw a segment with a given radius and color |
Instance:
[CPP]View Plaincopy
- Auto r= cocos2d::D rawnode::create ();
- AddChild (R);
- R->drawsegment (VEC2 (100,400), VEC2 (300,400), 2,color4f::red);
- R->drawsegment (VEC2 (200,500), VEC2 (200,300), 5,color4f::red);
Effect:
A straight line with a radius of 2 is drawn between coordinates 100,400 to 300,400, and a straight line with a radius of 200,300 is also drawn between coordinates 200,500 to 5.
3.drawPolygon draw a polygon, official explanation
void |
DrawPolygon (Vec2 *verts, int count, const color4f &fillcolor, float borderWidth, const color4f &bordercolor) |
|
Draw a polygon with a given fill color and line color |
Instance:
[CPP]View Plaincopy
- Auto r= cocos2d::D rawnode::create ();
- AddChild (R);
- VEC2 vc1[4]={vec2 (200,200), VEC2 (200,300), VEC2 (300,300), VEC2 (300,200)};
- R->drawpolygon (vc1,4,color4f::blue,1,color4f::red);
- VEC2 vc2[5]={vec2 (100,100), VEC2 (100,200), VEC2 (200,200), VEC2 (200,100), VEC2 (150,50)};
- R->drawpolygon (vc2,5,color4f::blue,1,color4f::red);
Effect:
The first polygon defines 4 points, and the second polygon has 5 points
cocos2dx3.x Drawing API (GO)