Cocos2d-x 绘图

前端之家收集整理的这篇文章主要介绍了Cocos2d-x 绘图前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

PS:在3.0以上不能直接重写draw()方法了,需要重写他的重构方法draw(cocos2d::Renderer *renderer,const cocos2d::Mat4& transform,uint32_t flags)


void RectA::draw(cocos2d::Renderer *renderer,uint32_t flags)
{
	//绘制空心矩形
	DrawPrimitives::drawRect(Point(0,0),Point(100,100));

	//绘制实心矩形
	DrawPrimitives::drawSolidRect(Point(0,100),Color4F(0,1,1));

	//绘制空心圆形 第一个参数是圆形,第二是半径,第三个是角度,第四个是绘制线多少,第五个是是否显示连接圆心的线
	DrawPrimitives::drawCircle(Point(0,50,M_PI*2,true);

	//绘制实心圆形
	DrawPrimitives::drawSolidCircle(Point(0,50);

	//绘制多边形  参数依次为多边形定点、定点数、是否闭合
	Point ps[3];
	ps[0] = Point(10,10);
	ps[1] = Point(100,0);
	ps[2] = Point(100,100);
	DrawPrimitives::drawPoly(ps,4,true);
	DrawPrimitives::drawSolidPoly(ps,3,1));*/

	//绘制线
	DrawPrimitives::drawLine(Point(0,100));

	//绘制点
	for(int x = 0;x<500;x++)
	{
		for (int y = 0; y < 500; y++)
		{
			DrawPrimitives::setDrawColor4B(rand()%256,rand()%256,255);
			DrawPrimitives::drawPoint(Point(x,y));
		}
	}

	DrawPrimitives::setDrawColor4B(255,255);
}
原文链接:https://www.f2er.com/cocos2dx/346010.html

猜你在找的Cocos2d-x相关文章