如何让精灵旋转到触摸Cocos2d
我有一个箭头精灵,它用于我的 Cocos2d 游戏中的瞄准目的。因此,我希望它指向用户触摸屏幕的位置。如何对精灵的旋转进行编程,使其旋转到用户的触摸位置?谢谢!
I have an arrow sprite, and it is for aiming purposes in my Cocos2d game. Therefore, I want it to point to where the user touches the screen. How do I program the rotation of the sprite so it will rotate to the user's touch location? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这些教程可能会有所帮助:
http://www.learn-cocos2d.com/knowledge-base/cocos2d-iphone-faq/learn-cocos2d-public-content/manual/cocos2d-general/14826-how-to-rotate-a-sprite -圆周运动/
http://www.raywenderlich.com/2343/ how-to-drag-and-drop-sprites-with-cocos2d
另外,这个问题在这里被问(用代码)并回答(用更多代码):通过触摸旋转精灵 - Cocos2d
These tutorials may be helpful:
http://www.learn-cocos2d.com/knowledge-base/cocos2d-iphone-faq/learn-cocos2d-public-content/manual/cocos2d-general/14826-how-to-rotate-a-sprite-in-a-circular-motion/
http://www.raywenderlich.com/2343/how-to-drag-and-drop-sprites-with-cocos2d
Also, this question is asked (with code) and answered (with more code) here: Rotating Sprite with Touch - Cocos2d
我之前实际上没有这样做过,但我已经根据您的需要调整了一些代码(使敌方船面向玩家船)。希望这是正确的。
PengOne 的答案(顺便说一句,很酷的名字)很棒,我投票赞成,因为你应该利用它。
I haven't actually done this before, but I have adapted some of my code (that makes a enemy ship face the player ship) to what you need. Hopefully this is correct.
PengOne's answer (cool name BTW) was great though and I am voting it up because you should make use of it.