进度条的创建,水平方向,垂直方向,动作,进度设定:@H_403_2@
@H_403_2@
Sprite* bg = Sprite::create("bg.png"); //创建一个进程条; ProgressTimer* loadProgress = ProgressTimer::create(Sprite::create("tiao.png")); loadProgress->setAnchorPoint(Vec2(0.5,0.5)); loadProgress->setBarChangeRate(Point(0,1));//设置进度的纵方向; loadProgress->setType(ProgressTimer::Type::BAR);//设置进程条的类型; loadProgress->setMidpoint(Point(0.5,0));//设置进度的水平方向; loadProgress->setPosition(Vec2(100.f,100.f)); bg->addChild(loadProgress); //设定进度; loadProgress->setPercentage(50.f); //设定动作; loadProgress->runAction(ProgressTo::create(2,50));注:setMidpoint(Point(0,0)) 和 setBarChangeRate(Point(1,0)); setMidpoint()函数是设置进度条的起始点,(0,y)表示最左边,(1,y)表示最右边,(x,1)表示最上面,(x,0)表示最下面。 setBarChangeRate()函数是用来设置进度条动画方向的,(1,0)表示横方向,(0,1)表示纵方向。