1、創建進度條對象
//精靈背景
CCSprite *progSprite = [CCSpritespriteWithFile:@"achievePlash.png"];
//初始化進度條
CCProgressTimer *prog = [CCProgressTimerprogressWithSprite:progSprite];
2、設置進度條屬性
//設置在場景中的位置
prog.position =ccp(winSize.width/2,100);
//設置進度條的類型
prog.type =kCCProgressTimerTypeBar;
//設置進度條每次變化的x,y位移,0則不變
prog.barChangeRate =ccp(1,0);
//設置進度條起始位置,左、下、爲0,右、上爲1
prog.midpoint = ccp(1, 0);
//設置當前百分比,注意,一定要設置完midpoint之後在設置percentage
prog.percentage = 50;
3、加入場景
[selfaddChild:progz:3tag:kprog];
4、調用
1、init中調用
[self scheduleUpdate]
2、update函數中
如果滿足條件,則
CCProgressTo *to = [CCProgressToactionWithDuration:timepercent:100];
[[selfgetChildByTag:kprg] runAction:to];