cocos2d-x进度条以及方向

来源:互联网 发布:技术支持 伯才网络 编辑:程序博客网 时间:2024/06/06 02:48

看到作者[wq右边]的博客【cocos2d-x初学笔记09:进度条Progress】

里面对进度条的方向理解的不清楚,自己做了一下实验


做进度条最基本需要三个元素:Sprite(进度条精灵),ProgressTo(百分比进度条,还有ProgressFromTo),ProgressTimer(正如其名,根据progressTo的百分比来渲染Sprite)


auto s = Sprite::createWithSpriteFrameName("grossini_dance_00.png");//进度条精灵,将要和ProgressTimer绑定ProgressTo* progress = ProgressTo::create(2, 100);//百分比进度条ProgressTimer* progressTimer = ProgressTimer::create(s);//绑定Sprite,根据百分比渲染内部的Sprite对象
//中间需要设置进度条的运行方式(旋转型,条形)
//此处设置旋转型
progressTimer->setType(ProgressTimer::Type::RADIAL);//顺时针旋转型
//此处设置条形
progressTimer->setType(ProgressTimer::Type::BAR);//设置为条形
//下面设置方向(表面现象,深入理解还看官方文档对着两个函数的解释,文字不好描述)progressTimer->setMidpoint(Point(0.5f, 1));//Point(x,y)纵向时y为1,由上至下,y为0,由下至上,横向时x为1,从右自左,x为0从左自右progressTimer->setBarChangeRate(Point(1, 0));//Point(x,y)x为1,横向,x为0,纵向
//设置完成
progressTimer->setPosition(Point(200,200));//设置进度条中心位置this->addChild(progressTimer);//添加进度条progressTimer->runAction(progress);//运行进度条


0 0