cocos2dx3.x Drawing API

Source: Internet
Author: User
Tags addchild

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
    1. Auto r= cocos2d::D rawnode::create ();
    2. AddChild (R);
    3. 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
    1. Auto r= cocos2d::D rawnode::create ();
    2. AddChild (R);
    3. R->drawsegment (VEC2 (100,400), VEC2 (300,400), 2,color4f::red);
    4. 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
    1. Auto r= cocos2d::D rawnode::create ();
    2. AddChild (R);
    3. VEC2 vc1[4]={vec2 (200,200), VEC2 (200,300), VEC2 (300,300), VEC2 (300,200)};
    4. R->drawpolygon (vc1,4,color4f::blue,1,color4f::red);
    5. VEC2 vc2[5]={vec2 (100,100), VEC2 (100,200), VEC2 (200,200), VEC2 (200,100), VEC2 (150,50)};
    6. 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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.