cocos2d Custom Controls

[size=medium]
对cocos2d的API不熟,写几个控件,略感吃力>_<
咱们现炒现卖,边打基础,边建高楼=。=

CCButton


CCTable
[url]http://www.cnblogs.com/eagley/archive/2011/12/16/2289991.html[/url]

CCScrollView
[url]http://www.cocos2d-iphone.org/?s=CCScrollView[/url]
[url]http://www.cocos2d-iphone.org/forum/tags/cctableview[/url]
[/size]


-(void)beforeDraw {
glEnable(GL_SCISSOR_TEST);
const CGFloat s = [[CCDirector sharedDirector] contentScaleFactor];
glScissor(self.position.x, self.position.y, viewSize_.width*s, viewSize_.height*s);
}
/**
* retract what's done in beforeDraw so that there's no side effect to
* other nodes.
*/
-(void)afterDraw {
glDisable(GL_SCISSOR_TEST);
}
-(void) visit
{
// quick return if not visible
if (!visible_)
return;

glPushMatrix();

if ( grid_ && grid_.active) {
[grid_ beforeDraw];
[self transformAncestors];
}
[self transform];
[self beforeDraw];
if(children_) {
ccArray *arrayData = children_->data;
NSUInteger i=0;

// draw children zOrder < 0
for( ; i < arrayData->num; i++ ) {
CCNode *child = arrayData->arr[i];
if ( [child zOrder] < 0 ) {
[child visit];
} else
break;
}

// self draw
[self draw];

// draw children zOrder >= 0
for( ; i < arrayData->num; i++ ) {
CCNode *child = arrayData->arr[i];
[child visit];
}

} else
[self draw];

[self afterDraw];
if ( grid_ && grid_.active)
[grid_ afterDraw:self];

glPopMatrix();
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值