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];