1 Bar形進度
CCSprite * proBack = CCSprite::create("barback.png");
proBack->setPosition(ccp(winSize.width/2 - 100,winSize.height/2));
addChild(proBack);
CCProgressTimer * left =
CCProgressTimer::create(CCSprite::create("bar.png"));
left->setPosition(ccp(winSize.width / 2 - 100, winSize.height / 2));
addChild(left);
left->setType(kCCProgressTimerTypeBar);
left->setMidpoint(ccp(1,0));
left->setBarChangeRate(ccp(1,1));
CCProgressTo * to = CCProgressTo::create(2, 120.0f);
left->runAction(CCRepeatForever::create(to));
setMidPoint(ccp(x,y));
setMidpoint(ccp(1,0));
x和y均為[0,1]的數值表示進度起始點。比如ccp(0,0)左下角,ccp(1,1)右上角。
setBarChangeRate(ccp(x,y));
x和y均為[0,1]的數值表示,表示水平方向和豎直方向的進度。比如ccp(0,1)表示只有y軸方向有進度。
2 Radial
CCSprite * proBack2 = CCSprite::create("radialback.png");
proBack2->setPosition(ccp(winSize.width / 2 + 100, winSize.height /2));
addChild(proBack2);
CCProgressTimer * right = CCProgressTimer::create(CCSprite::create(“radial.png”));
right->setPosition(ccp(winSize.width/2 + 100,winSize.height / 2));
addChild(right);
right->setType(kCCProgressTimerTypeRadial);
right->setMidpoint(ccp(0.5,0.5));
CCProgressTo * to2 = CCProgressTo::create(2,100.0f);
right->runAction(to2);
3 案例
T17CCProgressTo.h