cocos2d-iphone 3.X 进度条的实现

-(void) addProgressNode{
   CCProgressNode *progressBar = [CCProgressNode progressWithSprite:[CCSprite spriteWithImageNamed:@"Icon.png"]];
   [self addChild:progressBar];
   progressBar.position = ccp(0, 0);
   progressBar.anchorPoint = ccp(0,0);    //类似于图的内部坐标(自己定义的,不是标准名字),假如是(0,0),则是放在左下角一个点,这样的话如果position的坐标是(0,0),则可以在左下角显示全部图形
   progressBar.type = CCProgressNodeTypeBar;
   progressBar.midpoint = ccp(1,0);     //有点类似于图的内部坐标,定义一个点,然后递增趋势
   progressBar.barChangeRate = ccp(1, 0); //相当于调整像哪个方向递增(这个估计理解错误,不过试了很多次,可以控制横,竖,或者横竖组合方位移动)
   
   CCActionCallBlock *callBlock = [CCActionCallBlock actionWithBlock:^{
      progressBar.percentage += 1;
      if (progressBar.percentage >= 100) {
         progressBar.percentage = 0;
      }
   }];
   
   CCActionDelay *delay = [CCActionDelay actionWithDuration:.1];
   CCActionSequence *sequence = [CCActionSequence actionOne:callBlock two:delay];
   CCActionRepeatForever *repeat = [CCActionRepeatForever actionWithAction:sequence];
   [progressBar runAction:repeat];
}

代码测试可以运行,但是解释上面可能有误,因为我就是个新手,参考http://forum.cocos2d-swift.org/t/v3-1-beta-ccprogressnode-running-backwards/13342写的

你可能感兴趣的:(cocos2d-iphone 3.X 进度条的实现)