您的位置:首页 > 移动开发 > Cocos引擎

Cocos2d-x----------------------------------ProgressTimer进度条

2015-09-02 13:40 627 查看
1、创建方式

ProgressTimer * loadingBar=ProgressTimer::create(Sprite::create("play.png"));

2、设置进度条的类型
目前版本的cocos2dx3.6提供两种类型的进度条
ProgressTimerType::BAR 长度进度条
ProgressTimerType::RADIAL 时针型进度条
设置类型:

loadingBar->setType(ProgressTimerType::BAR);

3、设置进度条开始的点(长度进度条)

loadingBar->setMidpoint(Vec2(0,0));
Vec2(0,0) 左下角


Vec2(1,1) 右上角

4、设置进度条的方向(长度进度条)

loadingBar->setBarChangeRate(Vec2(1, 0));
Vec2(1, 0) 由左至右


Vec2(0, 1) 从下到上

5、设置旋转方向(时针型)

loadingBar->setReverseProgress(false);

6、通过在update函数里设置进度每帧增加,可以使得进度条缓慢增加

float percent =loadingBar->getPercentage() +
1;

loadingBar->setPercentage(((int)percent)%100);

7、时针型进度条:在进度条图片下面放置一个灰色的纯色图片,在进度显示的适合有看起来像是在加载的效果
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: