Cocos2d-x3.0 DrawNode画图

DrawNode作为一个节点用其画图形,可以使以后的交互更加灵活。

DrawNode* DrawLayer::shape()
{
    auto shape = DrawNode::create();
    static Point triangle[3];
    triangle[0] = Point(-100, -100);
    triangle[1] = Point(100, -100);
    triangle[2] = Point(0, 100);
    
    static Color4F green(0, 1, 0, 1);
    shape->drawPolygon(triangle, 3, green, 0, green);
    return shape;
    
}
调用:
 auto node = this->shape();
        node->setPosition(Point(200, 300));
        addChild(node);
效果:

Cocos2d-x3.0 DrawNode画图_第1张图片

你可能感兴趣的:(图形,cocos2d-x,DrawNode)