问题
In cocos2d-x 3.0 dont work ccDrawSolidRect. 3.0 api have class Rect, but i cant find documentation about it. How to draw simple color rect with cocos2d-x 3.0?
回答1:
You can use void drawRect( Point origin, Point destination );
declared in CCDrawingPrimitives.
Call this method inside draw() method of any subclass of CCNode like:
void TestNode::draw() {
drawRect(Point::Point(10,10), Point::Point(40,40));
}
回答2:
You can try
DrawPrimitives::drawRect(const cocos2d::Point origin, const cocos2d::Point destination);
回答3:
You can also use this code snippet:
auto rectNode = DrawNode::create();
Vec2 rectangle[4];
rectangle[0] = Vec2(-50, -50);
rectangle[1] = Vec2(50, -50);
rectangle[2] = Vec2(50, 50);
rectangle[3] = Vec2(-50, 50);
Color4F white(1, 1, 1, 1);
rectNode->drawPolygon(rectangle, 4, white, 1, white);
this->addChild(rectNode);
Reference: cocso2d-x forum
来源:https://stackoverflow.com/questions/19431922/how-to-draw-simple-rect-with-cocos2d-x-v3-0