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);
效果:
版权声明:本文博主原创文章。博客,未经同意不得转载。