递增和递减进度条CCProgressTimer
关于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的更多相关文章
- cocos2dx基础篇(21) 进度条CCProgressTimer
[3.x] (1)去掉 "CC" (2)CCProgressTimerType 改为强枚举 ProgressTimer::Type:: // RADIAL //扇形进度计时器 BA ...
- Android 自定义圆形旋转进度条,仿微博头像加载效果
微博 App 的用户头像有一个圆形旋转进度条的加载效果,看上去效果非常不错,如图所示: 据说 Instagram 也采用了这种效果.最近抽空研究了一下,最后实现的效果是这样: 基本上能模拟出个大概,代 ...
- 数字,字符串,time模块,文本进度条
数字和字符串 数字类型 整形 整数, 1/2/3/12/2019 整形用来描述什么, 身高/年龄/体重 age = 18 height = 180 浮点型 浮点数,小数 salary = 10 pri ...
- 超炫的HTML5粒子效果进度条 VS 如何规范而优雅地code
最近瞎逛的时候发现了一个超炫的粒子进度效果,有多炫呢?请擦亮眼镜! // _this.ch){ _this.particles.splice(i, 1); } }; this.Particle.p ...
- 练习题(登陆-进度条-微信接口判断qq-微信接口判断列车时刻表-)
1.写一个用户的登陆注册的界面,用户的密码用hashlib加密存在文件中,登陆时候,用户的密码要和文件中的密码一致才行 def sha(password): #加密函数 passwd = hashli ...
- [Cocos2d-x For WP8]Progress 进度条
Cocos2d-x可以有多种进度条的展示方式,进度条的种类是根据进度条运动的方向来区分,包括顺时针,逆时针,从左到右,从右到左,从下到上和从上到下6种方式,这和WP8的进度条是由很大的区别的.那么Co ...
- 基于CAShapeLayer和贝塞尔曲线的圆形进度条动画
通过CAShapeLayer和贝塞尔曲线搭配的方法,创建的简单的圆形进度条的教程先简单的介绍下CAShapeLayer1,CAShapeLayer继承自CALayer,可使用CALayer的所有属性2 ...
- 第33讲 UI组件_进度条ProcessBar和消息队列处理器handler
第33讲UI组件_进度条ProcessBar和消息队列处理器handler 1. 进度条ProcessBar 一个可视化的进度指示器,代表正在执行的耗时任务.可以为用户展示一个进度条,表示正在执行的任 ...
- Qt带进度条的启动界面(继承QSplashScreen,然后使用定时器)
通过继承QSplashScreen类,得到CMySplashScreen类,然后在CMySplashScreen中定义QProgressBar变量,该变量以CMySplashScreen为父类,这样就 ...
随机推荐
- Hibernate(九)HQL查询
一.Hibernate提供的查询方式 OID查询方式:主键查询.通过get()或者load()方法加载指定OID的对象查询结果为一个 HQL查询方式:通过Query接口使用HQL语言进行查询 QBC查 ...
- Codeforces B - Berland National Library
B. Berland National Library time limit per test 1 second memory limit per test 256 megabytes input s ...
- posix_memalign详细解释(转)——自定义对齐大小的内存分配函数
转载:http://hi.baidu.com/freelonely/blog/item/340341077c4d287302088189.html 预对齐内存的分配 在大多数情况下,编译器和C库透明地 ...
- 【Oracle】查询字段的长度、类型、精度、注释等信息
查询数据字典中字段的相关信息 SELECT T .column_name AS column_name, --列名 T .column_type AS column_type, ---字段类型 T . ...
- webservice系统学习笔记2-使用jdk的命令生成本地代码
使用jdk自带的命令wsimport生成远程服务的本地代码 C:\Documents and Settings\Administrator>wsimport -d E:\mhWorkspace\ ...
- python之函数用法round()
# -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法round() #http://www.cnblogs.com/hongfei/p/3 ...
- 身份证查询API
# -*- coding: utf-8 -*- #python 27 #xiaodeng #http://apistore.baidu.com/apiworks/servicedetail/113.h ...
- logging日志管理-将日志写入文件
# -*- coding: cp936 -*- # test.py #http://blog.chinaunix.net/uid-27571599-id-3492860.html #logging日志 ...
- Ubuntu的一些小技巧, 备忘
Ubuntu下打开Scroll Lock键盘灯 一直以为灯坏了, 后来发现在win7下工作正常... 原来是跟系统有关系的. 在Ubuntu18.04下可以通过这个命令开关Scroll Lock灯 # ...
- 自研DCI网络路由交换协议DCIP-白牌交换机时代的企业网络
一转眼从听华为3Com的路由交换课程到如今已经13年有余了,依稀记得第一节课的时候我带着老婆去听的课(老婆是日语系的.那时还是女朋友,并不懂网络,仅仅是跟着我去上课的).抢了个头排,讲师宋岩老师提问了 ...