Cocos2d-x常用功能-绘图API:绘制点、线条、圆形、矩形、多边形

Cocos2d-x常用功能-绘图API:绘制点、线条、圆形、矩形、多边形,第1张

概述第三阶段:常用功能4 primitive  /'prɪmɪtɪv/ adj. 原始的, 早期的 简单的; 粗糙的 n. 文艺复兴前的画家或雕刻家; 早期的艺术家 destination  /,destɪ'neɪʃ(ə)n/ n.  目的地, 终点 1.Cocos2d-x绘图API使用说明 class Shape: public Node { public : //重写 draw方法        

第三阶段:常用功能4

primitive /'prɪmɪtɪv/ adj.原始的,早期的 简单的; 粗糙的 n.文艺复兴前的画家或雕刻家; 早期的艺术家 destination /,destɪ'neɪʃ(ə)n/ n. 目的地,终点
1.Cocos2d-x绘图API使用说明 class Shape: public Node { public : //重写 draw方法 用DrawPrimitives virtual voID draw(){

};

bool init(){
return true ;
}

CREATE_FUNC(Shape);
};
2.Cocos2d-x绘制矩形
voID Rect::draw(){
DrawPrimitives::setDrawcolor4B(
255 , 0 ,216)">255 );
DrawPrimitives::drawRect(Point(
0 ),Point( 100 ,216)">100 )); }
3.Cocos2d-x绘制填充矩形
voID SRect::draw(){
DrawPrimitives::drawSolIDRect(Point(
100 ),color4F( 1 ,216)">1 )); } 4.Cocos2d-x绘制圆形 圆心,半径,角度,分隔的线段,是否绘制一个连到中心的线 voID Circle::draw(){
DrawPrimitives::drawCircle(Point(
50 ,M_PI* 2 , true ); } 5.Cocos2d-x绘制填充圆形 voID SCircle::draw(){
DrawPrimitives::setDrawcolor4B(
255 );
DrawPrimitives::drawSolIDCircle(Point(
50 ); } 6.Cocos2d-x绘制多边形 顶点 顶点得数目 是否关闭几何图形 #ifndef __L01DrawingAPI__poly__ #define __L01DrawingAPI__poly__
#include <iostream>
#include
<cocos2d.h>

using namespace cocos2d;

namespace jikexueyuan {

class poly: public Node{

private :
Point ps[
3 ];

public :
bool init();

voID draw();


CREATE_FUNC(poly);

};

}

#endif /* defined(__L01DrawingAPI__poly__) */


"poly.h" namespace jikexueyuan {
bool poly::init(){

ps[
0 ] = Point( 0 );
ps[
1 ] = Point( 2 ] = Point( 100 );

true ;
}


voID poly::draw(){
DrawPrimitives::drawpoly(ps,216)"> 3
,162)"> true );
}
}
7.Cocos2d-x绘制填充多边形 顶点、 顶点得数目、填充的颜色 #ifndef __L01DrawingAPI__Spoly__
#define __L01DrawingAPI__Spoly__

namespace jikexueyuan {


class Spoly: private :
Point points[
5 ];

bool init();
voID draw();

CREATE_FUNC(Spoly);
};

}

/* defined(__L01DrawingAPI__Spoly__) */


"Spoly.h" bool Spoly::init(){

points[
0 );
points[
100 );
points[
3 ] = Point( 50 );
points[
4 ] = Point( true ;
}

voID Spoly::draw(){

DrawPrimitives::drawSolIDpoly(points,216)"> 5
,216)">1 ));
}
} 8.Cocos2d-x绘制线条 起始点、目标点 voID line::draw(){
DrawPrimitives::drawline(Point(
100 )); } 9.Cocos2d-x绘制点 voID Points::draw(){

for ( int y = 0 ; y< 50 ; y++) {
int x= 0 ; x< 50 ; x++) {
DrawPrimitives::setDrawcolor4B(rand()%
256 ,rand()% 255 );
DrawPrimitives::drawPoint(Point(x,y));
}
}
} 总结

以上是内存溢出为你收集整理的Cocos2d-x常用功能-绘图API:绘制点、线条、圆形、矩形、多边形全部内容,希望文章能够帮你解决Cocos2d-x常用功能-绘图API:绘制点、线条、圆形、矩形、多边形所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1018938.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存