如何使用cocos2d制作特定方向的箭头?
我想要两个物体排成一排,如下所示,并让一个物体从下方拍摄它们,如下所示。
0 0 0 0 0 0
0
较低的物体始终处于其位置,并将拍摄到上面的一个, 我想制作箭头,因为用户将在 iPhone 的屏幕上移动手指,如下所示,
0 0 0 0 0 0
\
\
\
0
如果移动手指,则
0 0 0 0 0 0
|
|
|
0
在屏幕上向右移动一个手指,然后箭头应分别移动,如
0 0 0 0 0 0
/
/
/
0
我如何实现此逻辑,如果我有多个数组的图像并根据角度或其他方式使用它们,但我想要它的准确性。
谢谢
I want two few objects in one row, like below and have an object shooting them from downwards, like as below
0 0 0 0 0 0
0
The lower be always on its position, and will shoot to uper one,
I want to make arrow as user will move its finger on the screen of iPhone, like below
0 0 0 0 0 0
\
\
\
0
if move finger then
0 0 0 0 0 0
|
|
|
0
In move one finger on screen more towards right, then arrow should move respectively as
0 0 0 0 0 0
/
/
/
0
How can I implement this logic, should I have multiple images of arrays and use them according to angle, or what, but I want accuracy in it.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不需要多个图像......只需在 TouchMoved 方法中旋转箭头图像
即可尝试该代码。
There is no need of multiple images.... just rotate your arrow image in touchesMoved method
Try that code.
检查以下链接以在触摸移动时旋转图像
,您必须限制所需角度之间的角度
旋转图像
check the following link to rotate image on touch move
here you have to restrict angle between your desire angles
rotate image
正如 Anshul 和 Nikhil 所说,旋转箭头应该足以解决您的问题。
另外请注意,您可能需要创建箭头精灵,并在其底部中心设置一个锚点( 0.5, 0.5 ),以避免注意到箭头左右移动,具体取决于您的设置。
最好的,
As Anshul and Nikhil stated, rotating the arrow should adequately answer your problem.
Note additionally that you will probably need to create your arrow sprite with an anchor set at its bottom center ( 0.5, 0.5 ), to avoid noticing your arrow shift left and right, depending on your setup.
Best,