【DrawNode比较先进】cocos2dx3.0 DrawNode的使用

连接:http://blog.sina.com.cn/s/blog_923fdd9b0102uwip.html

auto s = Director::getInstance()->getWinSize();
    
    auto draw = DrawNode::create();
    addChild(draw, 10);
    
    // Draw 10 circles
//    画同心圆
    for( int i=0; i < 10; i++)
    {
        draw->drawDot(Point(s.width/2, s.height/2), 10*(10-i), Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1));
    }
    
    // Draw polygons
//    画大三角形
    Point points[] = { Point(s.height/4,0), Point(s.width,s.height/5), Point(s.width/3*2,s.height) };
    draw->drawPolygon(points, sizeof(points)/sizeof(points[0]), Color4F(1,0,0,0.5), 4, Color4F(0,0,1,1));
    
    // star poly (triggers buggs)
//    画多边形
    {
        const float o=80;
        const float w=20;
        const float h=50;
        Point star[] = {
            Point(o+w,o-h), Point(o+w*2, o),                        // lower spike
            Point(o + w*2 + h, o+w ), Point(o + w*2, o+w*2),        // right spike
//                          {o +w, o+w*2+h}, {o,o+w*2},                 // top spike
//                          {o -h, o+w}, {o,o},                         // left spike
        };
        
       

你可能感兴趣的:(cocos2d-x,c/c++)