关于scheduleUpdate看这篇即可

http://www.benmutou.com/blog/archives/56

接下来是示例代码:

        CCSize size = CCDirector::sharedDirector()->getWinSize();

        //创建二个精灵,一绿一红
CCSprite *psSprite1 = CCSprite::create("green.png");
CCSprite *psSprite2 = CCSprite::create("red.png"); //利用精灵创建进度条,并设置一些属性
progresstime1 = CCProgressTimer::create(psSprite1); //初始化CCProgressTimer
progresstime1->setPercentage(0.0f); //设置初始百分比的值
//progresstime1->setScale(3); //设置进度条大小为原始的3倍
progresstime1->setBarChangeRate(ccp(, )); //设置进度条的长度和高度开始变化的大小
progresstime1->setType(kCCProgressTimerTypeBar); //设置进度条为水平
progresstime1->setPosition(ccp(size.width/, size.height/)); //放置进度条位置 this->addChild(progresstime1, ); //加入Layer中 //利用精灵创建进度条,并设置一些属性
progresstime2 = CCProgressTimer::create(psSprite2); //初始化CCProgressTimer
progresstime2->setPercentage(100.0f); //设置初始百分比的值
//progresstime2->setScale(3); //设置进度条大小为原始的3倍
progresstime2->setBarChangeRate(ccp(, )); //设置进度条的长度和高度开始变化的大小
progresstime2->setType(kCCProgressTimerTypeBar); //设置进度条为水平
progresstime2->setPosition(ccp(size.width/, size.height/ - )); //放置进度条位置 this->addChild(progresstime2, ); //加入Layer中
this->scheduleUpdate();
void HelloWorld::update(float dt)
{
//CCProgressTimer *progresstime = static_cast(this->getChildByTag(100));
float ct1 = progresstime1->getPercentage(); //取得当前进度的百分比
float ct2 = progresstime2->getPercentage(); //取得当前进度的百分比 ct1 = ct1 + 0.5f; //每帧+0.5%
ct2 = ct2 - 0.5f; //如果进度条小于100%,设置进度条的百分比
if (ct1 <= )
{
CCLOG("progresstime1:%f, progresstime2:%f", ct1, ct2);
progresstime1->setPercentage(ct1);
progresstime2->setPercentage(ct2);
}
//如果进度条达到100%,则进入过渡场景,过渡场景会在2秒后进入主场景
else
{
CCTransitionFade *tScene = CCTransitionFade::create(, HelloWorld::scene(), ccWHITE);
CCDirector::sharedDirector()->replaceScene(tScene);
}
}

递增和递减进度条CCProgressTimer的更多相关文章

  1. cocos2dx基础篇(21) 进度条CCProgressTimer

    [3.x] (1)去掉 "CC" (2)CCProgressTimerType 改为强枚举 ProgressTimer::Type:: // RADIAL //扇形进度计时器 BA ...

  2. Android 自定义圆形旋转进度条,仿微博头像加载效果

    微博 App 的用户头像有一个圆形旋转进度条的加载效果,看上去效果非常不错,如图所示: 据说 Instagram 也采用了这种效果.最近抽空研究了一下,最后实现的效果是这样: 基本上能模拟出个大概,代 ...

  3. 数字,字符串,time模块,文本进度条

    数字和字符串 数字类型 整形 整数, 1/2/3/12/2019 整形用来描述什么, 身高/年龄/体重 age = 18 height = 180 浮点型 浮点数,小数 salary = 10 pri ...

  4. 超炫的HTML5粒子效果进度条 VS 如何规范而优雅地code

    最近瞎逛的时候发现了一个超炫的粒子进度效果,有多炫呢?请擦亮眼镜!   // _this.ch){ _this.particles.splice(i, 1); } }; this.Particle.p ...

  5. 练习题(登陆-进度条-微信接口判断qq-微信接口判断列车时刻表-)

    1.写一个用户的登陆注册的界面,用户的密码用hashlib加密存在文件中,登陆时候,用户的密码要和文件中的密码一致才行 def sha(password): #加密函数 passwd = hashli ...

  6. [Cocos2d-x For WP8]Progress 进度条

    Cocos2d-x可以有多种进度条的展示方式,进度条的种类是根据进度条运动的方向来区分,包括顺时针,逆时针,从左到右,从右到左,从下到上和从上到下6种方式,这和WP8的进度条是由很大的区别的.那么Co ...

  7. 基于CAShapeLayer和贝塞尔曲线的圆形进度条动画

    通过CAShapeLayer和贝塞尔曲线搭配的方法,创建的简单的圆形进度条的教程先简单的介绍下CAShapeLayer1,CAShapeLayer继承自CALayer,可使用CALayer的所有属性2 ...

  8. 第33讲 UI组件_进度条ProcessBar和消息队列处理器handler

    第33讲UI组件_进度条ProcessBar和消息队列处理器handler 1. 进度条ProcessBar 一个可视化的进度指示器,代表正在执行的耗时任务.可以为用户展示一个进度条,表示正在执行的任 ...

  9. Qt带进度条的启动界面(继承QSplashScreen,然后使用定时器)

    通过继承QSplashScreen类,得到CMySplashScreen类,然后在CMySplashScreen中定义QProgressBar变量,该变量以CMySplashScreen为父类,这样就 ...

随机推荐

  1. Java从零开始学二十一(集合List接口)

    一.List接口 List是Collection的子接口,里面可以保存各个重复的内容,此接口的定义如下: public interface List<E> extends Collecti ...

  2. GraphQL返回分页对象

    private GraphQLOutputType testUserOutputType; private GraphQLOutputType pageType; private void initO ...

  3. hdu4059The Boss on Mars 容斥原理

    //求1到n之间与n互质的数的四次方的和 //segma(n^4) = (6n^5+15n^4+10n^3-n)/30 //对于(a/b)%mod能够转化为(a*inv(b))%mod //inv(b ...

  4. windows命令:control命令

    Windows的命令列模式下有个非常好用的命令叫做Control.这个命令其实就是控制『控制台』的一个接口.你可以用这个命令直接叫起一些平常要找很久才会找到的窗口.最简单的一个例子,你只要在『开始』 ...

  5. ajax-原理分析

      createTime--2016年9月19日13:59:11Author:Marydon参考链接 http://blog.csdn.net/csh624366188/article/details ...

  6. webservice系统学习笔记3-分析wsdl文件的组成

    详细分析前面章节的服务的wsdl文件 1.http://localhost:8888/ws01?wsdl 2.http://localhost:8888/ws01?xsd=1 在接口服务中添加复杂类型 ...

  7. Web Service——CXF

    1. 什么是CXF Apache CXF = Celtix + Xfire,开始叫 Apache CeltiXfire,后来更名为 Apache CXF 了,以下简称为 CXF.Apache CXF ...

  8. HDUOJ----2512一卡通大冒险

    一卡通大冒险 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Subm ...

  9. java 移位

    java中没有2进制的数据类型,对二进制的操作,需要使用三种操作符 << 左移位操作符,算数左移           用来将一个数的二进制位序列左移若干位,高位左移后溢出,舍弃不用,右补0 ...

  10. Atom 检测php错误扩展linter-php