进度条特效
程序员文章站
2024-02-02 11:26:16
...
效果图:
代码:
//条形进度条
void LoginScene::progressBarTest()
{
//背景
Sprite* spBg = Sprite::create("room/21dian/gamescene/img_xz_bg.png");
spBg->setVisible(true);
spBg->setPosition(Vec2(960, 400));
csb->addChild(spBg);
//进度
Sprite* spJd = Sprite::create("room/21dian/gamescene/img_xz_js.png");
spJd->setVisible(true);
//控件
auto progressTimer = ProgressTimer::create(spJd);
progressTimer->setPosition(spBg->getPosition());
progressTimer->setType(ProgressTimer::Type::BAR);//BAR条形,RADIAL扇形
//----从右到左
progressTimer->setMidpoint(ccp(0, 0.5));
progressTimer->setBarChangeRate(ccp(1, 0));
////----从左到右
//progressTimer->setMidpoint(ccp(1, 0.5));
//progressTimer->setBarChangeRate(ccp(1, 0));
////----从下到上
//progressTimer->setMidpoint(ccp(0.5, 1));
//progressTimer->setBarChangeRate(ccp(0, 1));
////----从上到下
//progressTimer->setMidpoint(ccp(0.5, 0));
//progressTimer->setBarChangeRate(ccp(0, 1));
//
progressTimer->setPercentage(100);
csb->addChild(progressTimer);
////创建进度动作CCProgressTo、CCProgressFromTo
////进度动作
//CCProgressTo* ac1 = CCProgressTo::create(2.0f, 100);
//progressTimer->runAction(CCRepeatForever::create(ac1)); //2秒内,从0到100
CCProgressFromTo* ac2 = CCProgressFromTo::create(10.0f, 100, 0);
progressTimer->runAction(CCRepeatForever::create(ac2));//10秒内,从100到0
//反进度显示setReverseProgress()
//progressTimer->setReverseProgress(true); //反进度显示
//progressTimer->setReverseProgress(true); //逆时针
}
上一篇: 第一个Vue实例:数据绑定
下一篇: Android圆形进度条