cocos2d画图

原文: 想要在layer中画一个圆,找到的cocos2d中的一些画图的例子代码

 

- (void) draw{

    CGSize s = [[CCDirector sharedDirectorwinSize];

 

// draw a simple line

// The default state is:

// Line Width: 1

// color: 255,255,255,255 (white, non-transparent)

// Aliased

ccDrawLineccp(00), ccp(s.width, s.height) );

 

// line: color, width, anti-aliased

glLineWidth5.0f );

glEnable(GL_LINE_SMOOTH);

glColor4ub(255,0,0,255);

ccDrawLineccp(0, s.height), ccp(s.width0) );

    

// TIP:

// Since nobody disabled GL_LINE_SMOOTH,

// it will be valid until somone disabled it.

// The followin examples will be drawn using anti-aliasing.

//

// Remember: OpenGL is a state-machine.

 

// draw big point in the center

glPointSize(64);

glColor4ub(0,0,255,128);

ccDrawPointccp(s.width 2, s.height 2) );

 

// draw 4 small points

CGPoint points[] = { ccp(60,60), ccp(70,70), ccp(60,70), ccp(70,60) };

glPointSize(4);

glColor4ub(0,255,255,255);

ccDrawPoints( points, 4);

 

// draw a green circle with 10 segments

glLineWidth(16);

glColor4ub(02550255);

ccDrawCircleccp(s.width/2 s.height/2), 100010NO);

    

// draw a green circle with 50 segments with line to center

glLineWidth(2);

glColor4ub(0255255255);

ccDrawCircleccp(s.width/2, s.height/2), 50CC_DEGREES_TO_RADIANS(90), 50YES);

 

// open yellow poly

glColor4ub(2552550255);

glLineWidth(10);

CGPoint vertices[] = { ccp(0,0), ccp(50,50), ccp(100,50), ccp(100,100), ccp(50,100) };

ccDrawPoly( vertices, 5NO);

 

// closed purble poly

glColor4ub(2550255255);

glLineWidth(2);

CGPoint vertices2[] = { ccp(30,130), ccp(30,230), ccp(50,200) };

ccDrawPoly( vertices2, 3YES);

 

 

// restore original values

glLineWidth(1);

glDisable(GL_LINE_SMOOTH);

glColor4ub(255,255,255,255);

glPointSize(1);

 

}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值