欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

进度条特效

程序员文章站 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); //逆时针

}

 

相关标签: 进度条特效