Home  >  Article  >  Database  >  cocos2dx 3.0 绘制图形

cocos2dx 3.0 绘制图形

WBOY
WBOYOriginal
2016-06-07 15:12:541296browse

在3.0里面的图形绘制已经取消draw()的node绘制图形的方法,可以直接写代码绘制图形界面。 DrawNode* drawNode = DrawNode::create();drawNode-drawTriangle(Point(100, 100), Point(200, 200), Point(300, 100), Color4F::BLUE);this-addChild(drawNode);Dra

在3.0里面的图形绘制已经取消draw()的node绘制图形的方法,可以直接写代码绘制图形界面。

	DrawNode* drawNode = DrawNode::create();
	drawNode->drawTriangle(Point(100, 100), Point(200, 200), Point(300, 100), Color4F::BLUE);
	this->addChild(drawNode);

	DrawNode* front=DrawNode::create();
	Point rect[4] = {ccp(-30, 30), ccp(30, 30), ccp(30, -30), ccp(-30, -30)};
	front->drawPolygon(rect, 4, Color4F::RED, 0, Color4F::BLUE);
	front->setPosition(Point(240, 160));
	this->addChild(front);

drawTriangle是绘制三角形的方法,参数为三个顶点的位置和填充颜色。

drawPolygon是绘制矩形的方法,具体参数可以直接由API

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn