CCProgressAction进度条动作的使用(扇形和条形)

CCProgressAction进度条动作的使用(扇形和条形)

扇形进度条的使用:ProgressTo, ProgressFromTo, ProgressTimer 的使用

 

 1     ///////// 扇形进度条的使用  ////////////////////
 2     
 3     // 执行的动作,进度条的动作
 4     // 参数(时间,完成度(100:表示全部显示))
 5     ProgressTo *progressTo = ProgressTo::create(5.0f, 100);    // 从 0 开始
 6     //ProgressFromTo *progressFromTo = ProgressFromTo::create(5.0f, 30, 80);    // 从 30 开始 到 80 结束
 7 
 8     // 创建进度条,并且配置一些属性
 9     // 参数(精灵)
10     ProgressTimer *progressTimer = ProgressTimer::create(Sprite::create("HelloWorld.png"));
11     progressTimer->setPosition(visibleSize.width / 2, visibleSize.height / 2);
12     addChild(progressTimer);
13 
14     // 设置类型为扇形
15     progressTimer->setType(kCCProgressTimerTypeRadial);
16     // 设置扇形圆心的位置
17     progressTimer->setMidpoint(Vec2(0.2f, 0.2f));
18 
19     progressTimer->runAction(progressTo);
20     //progressTimer->runAction(progressFromTo);
21 
22     ///////// 扇形进度条的使用  ////////////////////

 

 

 

结果:

 

 

条形进度条的使用

 

 

 1     ///////// 条形进度条的使用  ////////////////////
 2 
 3     // 执行的动作,进度条的动作
 4     // 参数(时间,完成度(100:表示全部显示))
 5     ProgressTo *progressTo = ProgressTo::create(5.0f, 100);
 6 
 7     // 创建进度条,并且配置一些属性
 8     // 参数(精灵)
 9     ProgressTimer *progressTimer = ProgressTimer::create(Sprite::create("HelloWorld.png"));
10     progressTimer->setPosition(visibleSize.width / 2, visibleSize.height / 2);
11     addChild(progressTimer);
12 
13     // 设置类型为条形
14     progressTimer->setType(kCCProgressTimerTypeBar);
15     // 这两个一起使用
16     // 设置进度条的轴,是 x轴(横向) 运动,还是 y轴(竖向) 运动 
17     // 横向 : x = 1, y = 0;    竖向 : x = 0, y = 1;
18     //progressTimer->setBarChangeRate(Vec2(1,0));    // 横向
19     progressTimer->setBarChangeRate(Vec2(0, 1));    // 竖向
20     //progressTimer->setBarChangeRate(Vec2(1,1));    // 对角线开始变化
21     //progressTimer->setBarChangeRate(Vec2(0, 0));    // 无变化
22 
23     // 设置进度条运动方向,
24     // x轴是从 左到右 (x = 0, y = 0(跟y值无关)),还是从 右到左 (x = 1, y = 0(跟y值无关)),
25     // y轴是从 上到下 (x = 0, y = 0(跟x值无关)),还是从 下到上 (x = 0, y = 0(跟x值无关))
26     //progressTimer->setMidpoint(Vec2(0, 0));        // 横向 从左到右
27     //progressTimer->setMidpoint(Vec2(1, 0));        // 横向 从右到左
28 
29     //progressTimer->setMidpoint(Vec2(0, 0));        // 竖向 从下到上
30     progressTimer->setMidpoint(Vec2(0, 1));        // 竖向 从上到下
31 
32     // 对角线 变化
33     //progressTimer->setMidpoint(Vec2(0, 1));        // 左上脚 从上到下
34     //progressTimer->setMidpoint(Vec2(0, 0));        // 左上脚 从下到上
35     //progressTimer->setMidpoint(Vec2(1, 1));        // 右上脚 从上到下
36     //progressTimer->setMidpoint(Vec2(1, 0));        // 右上脚 从下到上
37 
38 
39     progressTimer->runAction(progressTo);
40 
41     ///////// 条形进度条的使用  ////////////////////

 

 

 

 

结果:

 

posted @ 2015-06-06 08:26  silent-bobo  阅读(1101)  评论(0编辑  收藏  举报