CCProgressTimerの実装例
2012/04/21
cocos2d
ios
cocos2dです。
CCProgressTimerの実装例です。
CCProgressTimer *timer = [CCProgressTimer progressWithSprite:[CCSprite spriteWithFile:@"Icon.png"]];
// timer.type = kCCProgressTimerTypeRadial;
// timer.type = kCCProgressTimerTypeBar;
timer.percentage = 0;
timer.position = ccp(size.width/2,size.height/2);
[self addChild:timer z:1 tag:123];
[self scheduleUpdate];
updateの実装はこんな感じ?
-(void)update:(ccTime)dt
{
//progress bar
CCNode* node = [self getChildByTag:123];
CCProgressTimer *timer = (CCProgressTimer*)node;
timer.percentage += dt * 10;// 1sec?
if (timer.percentage >= 100) {// 10sec?
timer.percentage = 0;
}
}
kCCProgressTimerTypeRadialは以下
kCCProgressTimerTypeBarは以下
: