在cocos2d中设置功率计
我是个直菜鸟。别人都这么说,但我是认真的。
我的问题是,制作功率计来移动物体的最佳方法是什么?意思是,如何设置才能使玩家持有的时间越长,获得的力量就越大。另外,我将如何融入物理?
我想要实现的是让玩家抓住某物,这样当他点击屏幕并按住时,他就会增强力量,而当他放手时,他就会将物体扔出一定的距离。
I am a straight noob. Everyone else says it, but I'm dead serious.
My question is, what is the best way to make a power meter to move a object? Meaning, how to set it up so that the longer the player holds the more power they get. Also how, would I incorporate physics?
What I'd like to accomplish is to have a player holding onto something so that when he taps on the screen and hold he powers up, and when he lets go he throws the object a certain distance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是检查是否有任何触摸序列是一件相当简单的事情,您只需为场景类重载两个函数,一个在触摸序列开始时通知您,另一个告诉您触摸结束。源代码示例在此链接中描述。之后我认为你需要一个仪表来显示到目前为止收集了多少功率,最简单的方法是使用其中显示全功率的纹理并将其设置为纹理,然后随着功率的增加逐渐显示它正如下面的代码:
请注意,在我的代码中,我使用 100x10 纹理(功率介于 0..100 之间,纹理高度为 10 作为两个 CGRectMake 函数中的最后一个参数)
just checking if the there is any thouch sequence or not is rather an easy thing, you just have to overload two functions for your scene class, one to inform you whenever a touch sequence begins and one to tell you touch is ended. the source code example is describe in this link. after than i think you need a gauge to show how much power is gathered so far, the easiest way is to use a texture with full power shown in it and the set it as texture and then show it little by little as the power goes up just as the code below:
note that in my code i am using a 100x10 texture (power is somthing between 0..100 and texture height is 10 as the last parameter in both CGRectMake functions)