我的Cocos2d-x学习笔记(十七)CCProgressTo
2015-06-03 09:54
621 查看
Cocos2d-x提供了进度条动作,该类继承CCActionInterval。继承关系如下:
在使用CCProgressTo时还需要CCProgressTimer。
在CCProgressTimer类中,仅仅只有一个create函数用来创建,其参数是一个精灵,如下:
CCProgressTimer在创建后,还需要设置一些其他参数。
CCProgressTo类中也仅仅有一个create用来创建,代码如下:
float fPercent:进度条的百分比,100是进度条满。
一、辐射性进度条
实例:
setType:用来设置进度条的类型。
setMidpoint:用来设置旋转中心。
setReverseProgress:用来设置进度条执行方向,默认是顺时针。
Midpoint与BarChangeRate声明如下:
实例:
在使用CCProgressTo时还需要CCProgressTimer。
在CCProgressTimer类中,仅仅只有一个create函数用来创建,其参数是一个精灵,如下:
static CCProgressTimer* create(CCSprite* sp);
CCProgressTimer在创建后,还需要设置一些其他参数。
CCProgressTo类中也仅仅有一个create用来创建,代码如下:
/** Creates and initializes with a duration and a percent */ static CCProgressTo* create(float duration, float fPercent);float duration:进度条执行完需要的时间。
float fPercent:进度条的百分比,100是进度条满。
一、辐射性进度条
实例:
CCProgressTo* radial = CCProgressTo::create(2, 100); CCProgressTimer* radialProgress = CCProgressTimer::create(CCSprite::create("btn_go_0.png")); radialProgress->setType(kCCProgressTimerTypeRadial); radialProgress->setPosition(ccp(100,100)); radialProgress->setMidpoint(ccp(0.1,0.2)); radialProgress->setReverseProgress(true); radialProgress->runAction(radial); addChild(radialProgress);
setType:用来设置进度条的类型。
setMidpoint:用来设置旋转中心。
setReverseProgress:用来设置进度条执行方向,默认是顺时针。
Midpoint与BarChangeRate声明如下:
/** * Midpoint is used to modify the progress start position. * If you're using radials type then the midpoint changes the center point * If you're using bar type the the midpoint changes the bar growth * it expands from the center but clamps to the sprites edge so: * you want a left to right then set the midpoint all the way to ccp(0,y) * you want a right to left then set the midpoint all the way to ccp(1,y) * you want a bottom to top then set the midpoint all the way to ccp(x,0) * you want a top to bottom then set the midpoint all the way to ccp(x,1) */ CC_PROPERTY(CCPoint, m_tMidpoint, Midpoint); /** * This allows the bar type to move the component at a specific rate * Set the component to 0 to make sure it stays at 100%. * For example you want a left to right bar but not have the height stay 100% * Set the rate to be ccp(0,1); and set the midpoint to = ccp(0,.5f); */ CC_SYNTHESIZE(CCPoint, m_tBarChangeRate, BarChangeRate);二、条状进度条
实例:
CCProgressTimer * barProgress = CCProgressTimer::create(CCSprite::create("btn_go_0.png")); CCProgressTo * bar = CCProgressTo::create(2, 100); barProgress->setType(kCCProgressTimerTypeBar); barProgress->setMidpoint(ccp(1,0)); barProgress->setBarChangeRate(ccp(1,1)); barProgress->setPosition(ccp(200, 100)); barProgress->runAction(bar); addChild(barProgress);具体辐射性进度条已经解释。
相关文章推荐
- cocos2d-x 减少游戏耗电量
- cocos2d-x打包2.X安卓流程(不使用CWY)
- flatbuffers 在cocos2dx中的应用
- 我理解的 cocos2d_x3.4 的单点触摸机制
- cocos2d-x 3.0 触摸机制的使用
- cocos2dx android工程接入联通Unipay sdk
- 安卓加载动画崩溃
- 屏蔽多点触摸
- cocos2d-x 3.1 集成 云风pbc
- 安卓白屏问题
- 我的cocos2d-x-3.2集成云风pbc lua binding方法
- cocos2dx 自定义menu 添加到scrollview上可以滑动
- 我的Cocos2d-x学习笔记(十六)动作
- Cocos2d-x-3.6命令行安装
- 在Quick-cocos2dx中使用云风pbc解析Protocol Buffers,支持win、mac、ios、android
- cocos2dx安装
- 【深入了解cocos2d-x 3.x】定时器(scheduler)的使用和原理探究(1)
- cocos2dx CCLabelTTF 字体自动换行
- Cocos2dx 3.0 -- lambda表达式的使用
- 用封装ClippingNode实现新手引导(cocos2dx 3.2版本)