在纸牌游戏中翻转纸牌
我开发了一款游戏,当用户触摸卡片时,卡片会缓慢翻转并显示数字。 为此,我可以使用什么 cocos2d API?
或者我应该创建带有指示翻转的帧的动画?
I develop a game where when user touches a card it'll flip slowly and number will show up.
For that purpose , what cocos2d API can I use ?
Or should I create animation with frames indicating the flip?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以创建类似于 CCTransitionFlipX 的内容。但不是 CCScene,而是让它在您的卡片节点(精灵)上运行。
以下是此类的实现 (CCTransition.m):
基本上,它在给定持续时间的两个场景上运行一系列 CCAction。
CCOrbitCamera
操作使用球坐标使相机绕屏幕中心旋转。You can create something similar to
CCTransitionFlipX
. But instead of CCScene let it operate on your card nodes (sprites).Here is the implementation of this class (CCTransition.m):
Basically it runs a sequence of CCActions on both scenes with the given duration. The
CCOrbitCamera
action orbits the camera around the center of the screen using spherical coordinates.对于翻转视图,您可以这样做,
在执行动画之前,只需创建一个标签并将其作为子视图添加到 UIView 中。将文本设置为您想要在动画后显示的数字。隐藏此标签。在 commitAnimations 之后的动画结束时,只需将标签的隐藏属性设置为 NO。我猜你会实现你想要的动画风格..希望这有帮助....编码愉快...:)
For Flipping a view u can do it like this ,
Before doing animation just create a label and add it as a subview to the UIView. Set the text to the number u want to display after the animation.Hide this label.At the end of the animation that is after commitAnimations just set the hidden property of the label to NO. You will achieve the animation style u want , i guess.. Hope this helps....Happy coding... :)
GeekGameBoard 是一个 Mac 应用程序,其中有很多里面有游戏。它还具有处理翻转等的卡类。希望有帮助!
GeekGameBoard is a mac app which has a bunch of games in it. It also has a card class which handles flips and the like. Hope that Helps!
我在 cocs2d-android-1 中这样做
I do in cocs2d-android-1 like that