在cocos2d中同样提供了很多表现图片和精灵的方式,上一篇当中提到的切换场景的方式之一是顺或逆时针切入的方法,在图片上也可以使用,test里有一个例子介绍CCProgresstimer可以实现一些图片的特效效果,这样的效果可以在载入的时候作为载入动画
voID SpriteProgresstoRadial::onEnter(){ SpriteDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCProgressto *to1 = CCProgressto::create(2,100); CCProgressto *to2 = CCProgressto::create(2,100); CCProgresstimer *left = CCProgresstimer::create(CCSprite::create(s_pPathSister1)); left->setType( kCCProgresstimerTypeRadial ); addChild(left); left->setposition(ccp(100,s.height/2)); left->runAction( CCRepeatForever::create(to1)); CCProgresstimer *right = CCProgresstimer::create(CCSprite::create(s_pPathBlock)); right->setType(kCCProgresstimerTypeRadial); // Makes the rIDial ccw right->setReverseProgress(true); addChild(right); right->setposition(ccp(s.wIDth-100,s.height/2)); right->runAction( CCRepeatForever::create(to2));}
1.定义CCProgressto,通过actionWithDuration或者create函数,第一个参数是时间是一个CCTime对象,第二个参数是结果显示图片的百分比
2.定义CCProgresstimer,通过progressWithfile或者create,参数是图片路径
3.调用setType设置类型,
4.设置位置,没什么好说的,直接setposition
5.开始,使用CCRepeatForever(重复进行),传入CCProgressto对象
kCCProgresstimerTypeRadialCW顺时针生成
kCCProgresstimerTypeRadialccw逆时针生成
kCCProgresstimerTypeHorizontalbarLR从左到右生成
kCCProgresstimerTypeHorizontalbarRL从右到左生成
kCCProgresstimerTypeVerticalbarBT从下到上生成
kCCProgresstimerTypeVerticalbarTB从上到下生成
总结以上是内存溢出为你收集整理的cocos2d-x--CCProgressTimer全部内容,希望文章能够帮你解决cocos2d-x--CCProgressTimer所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)