如何绘制圆形条形?
我正在用 cocos2d-iphone 开发一个游戏。
我想要一个很棒的圆形健康栏。想想王国之心之类的。
我可以使用 ccDrawLine 绘制圆圈,但它们是完整的圆圈。基本上,我需要能够绘制出一定的周长值来正确表示健康状况。不过,我对此不太确定。有什么想法吗?
I am devleoping a game with cocos2d-iphone.
I want to great a circular health bar. Think of Kingdom Hearts or something.
I am able to draw circles with ccDrawLine
, but they are full circles. Basically, I need to be able to draw up to a certain circumference value to represent the health properly. However, I am not really sure about this. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我快速浏览了 ccDrawCircle 的代码。如果我正在接近这个,我可能会首先修改
for
循环的工作方式(也许通过使用coef
或segs
),这样它提前停止了。I had a quick look at the code for ccDrawCircle. If I was approaching this, I'd probably start by modifying the way the
for
loop works (maybe by playing withcoef
orsegs
) so that it stops early.CGContextAddArc() 就可以了。一个例子就说明了一切。
我不太确定参数的顺序,你最好用谷歌搜索一下或者让 XCode 帮你完成工作。
CGContextAddArc() will do the trick. An example explains everything.
I'm not quite sure about the order of the parameters, you'd better google it or let XCode do the work for you.