8,303
社区成员
发帖
与我相关
我的任务
分享
void SpriteProgressWithSpriteFrame::onEnter()
{
SpriteDemo::onEnter();
auto s = Director::getInstance()->getWinSize();
auto to = Sequence::createWithTwoActions(ProgressTo::create(6, 100), ProgressTo::create(0, 0));
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("zwoptex/grossini.plist");
auto left = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_01.png"));
left->setType(ProgressTimer::Type::BAR);
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
left->setMidpoint(Vec2(0.5f, 0.5f));
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
left->setBarChangeRate(Vec2(1, 0));
addChild(left);
left->setPosition(Vec2(100, s.height/2));
left->runAction(RepeatForever::create(to->clone()));
auto middle = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_02.png"));
middle->setType(ProgressTimer::Type::BAR);
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
middle->setMidpoint(Vec2(0.5f, 0.5f));
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
middle->setBarChangeRate(Vec2(1, 1));
addChild(middle);
middle->setPosition(Vec2(s.width/2, s.height/2));
middle->runAction(RepeatForever::create(to->clone()));
auto right = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_03.png"));
right->setType(ProgressTimer::Type::RADIAL);
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
right->setMidpoint(Vec2(0.5f, 0.5f));
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
right->setBarChangeRate(Vec2(0, 1));
addChild(right);
right->setPosition(Vec2(s.width-100, s.height/2));
right->runAction(RepeatForever::create(to->clone()));
}