Cocos2d-x   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了cocos2d-x 3.X用progressTimer制作血槽大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

http://www.2cto.com/kf/201403/289326.html


血条经常会用到,没必要重复编写浪费时间,这里用最新版的API写个,方便以后调用。

以下代码使用的引擎版本是cocos2d-x 3.0rc0

1.RADIAL


Sprite *bgSprite = Sprite::create( "red.png" );
addChild(bgSprite, 1 ,monospace!important; font-size:1em!important; min-height:auto!important; color:black!important; BACkground:none!important">);
Sprite *hpSprite = Sprite::create( "green.png" );
progressTimer = ProgressTimer::create(hpSpritE);
//设置进度条的模式
//kCCProgressTimerTypeBar表示条形模式
//默认的模式是kCCProgressTimerTypeRadial(圆圈模式)
progressTimer->setType(ProgressTimer::Type::rADIAL);
progressTimer->setReverseProgress( true );
progressTimer->setPercentage( 30 ); //满值 100%
addChild(progressTimer,0)!important; BACkground:none!important">0 );

2.bAR


"box.png" "hp.png"
progressTimer->setType(ProgressTimer::Type::BAR);
///////////////////////////////////////////////////////////////////////////////////////////////////////
//从左到右
progressTimer->setMidpoint(ccp( 0.5 ));
progressTimer->setBarChangeRate(ccp( ));
//设置进度条变化的方向
//setMidpoint默认在左边
//ccp(1,0)表示在X轴方向上有变化,在y轴方向上没变化
//ccp(0,1)表示在X轴方向上没有变化,在y轴方向上有变化

//从右到左
// progressTimer->setMidpoint(ccp(1,0.5));
// progressTimer->setBarChangeRate(ccp(1,0));
//从上到下
// progressTimer->setMidpoint(ccp(0.5,1));
// progressTimer->setBarChangeRate(ccp(0,1));
//从下到上
number24 index23 alt1" style="list-style:none; line-height:15.3999996185303px; font-family:Consolas,0));
number25 index24 alt2" style="list-style:none; line-height:15.3999996185303px; font-family:Consolas,1));
///////////////////////////////////////////////////////////////////////////////////////////////////////////
progressTimer->setMidpoint(Point( ));
progressTimer->setBarChangeRate(Point( ));
//满值 100%

大佬总结

以上是大佬教程为你收集整理的cocos2d-x 3.X用progressTimer制作血槽全部内容,希望文章能够帮你解决cocos2d-x 3.X用progressTimer制作血槽所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。