Cocos2d-x 3.4 进度条
旋转进度条
auto s = Director::getInstance()->getWinSize();
auto to1 = Sequence::createWithTwoActions(ProgressTo::create(2,100),ProgressTo::create(0,0));//旋转进度条
auto left = ProgressTimer::create(Sprite::create("Images/grossini.png"));
left->setType(ProgressTimer::Type::RADIAL);
left->setReverseProgress(true);//反转执行
addChild(left);
left->setPosition(100,s.height/2);
left->runAction(RepeatForever::create(to1));
水平进度条
auto to2 =
auto left = Type::BAR);//BAR 水平进度条
left->setMidpoint(Vec2(1,0));//从右到左 ,Vec2(0,0)为从左到右
left->setBarChangeRate(
addChild(left);
left->setPosition(100,175); font-family:新宋体; font-size:9.5pt">RepeatForever::create(to2));
垂直进度条
auto t3 = Type::BAR);
left->setMidpoint(Vec2(0,1));//从上到下,Vec2(0,0)为从下到上
left->setBarChangeRate(
addChild(left);
left->setPosition(100,175); font-family:新宋体; font-size:9.5pt">RepeatForever::create(t3));
BAR类型进度条设置变化
auto t5 = Vec2(0.5f,0.5f));
left->setBarChangeRate(//从中心向四周扩散,Vec2(1,0)从中心向两边扩散,Vec2(0,1)从中心向山下扩散
addChild(left);
left->setPosition(s.width/2,175); font-family:新宋体; font-size:9.5pt">RepeatForever::create(t5));
可变换旋转中心的旋转进度条
auto t4 = Type::RADIAL);
left->setMidpoint(Vec2(0.75f,0.25f));//设置旋转中心点
left->setBarChangeRate(RepeatForever::create(t4));
进度条搭配其他动作
auto t6 = ProgressTo::create(6,0));
auto hint = Sequence::create(TintTo::create(1,255,0),255),nullptr);
auto left =
left->runAction(RepeatForever::create(t6->clone()));
left->runAction(RepeatForever::create(hint->clone()));
auto t7 =
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("zwoptex/grossini.plist");
auto left = Sprite::createWithSpriteFrameName("grossini_dance_01.png"));
left->setMidpoint(
left->setBarChangeRate(
addChild(left);
left->setPosition(300,300);
left->runAction(RepeatForever::create(t7->clone()));