查找球的目标位置 [英] Find destination position of ball
本文介绍了查找球的目标位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何根据触摸角度移动球,如果它碰到墙壁,球会反射?
How to move the ball dependent on touch angle and make the ball reflect if it touches the wall?
CGFloat diffX = ballImg.position.x - tchLoc.x;
CGFloat diffY = ballImg.position.y - tchLoc.y;
CGFloat angleRadian = atan2f(diffY, diffX);
float angleDegrees=CC_RADIANS_TO_DEGREES(angleRadian);
推荐答案
我认为你已经把你的球精灵。所以在touchesBegan,你会得到触摸位置,然后你可以使用CCMoveTo动作移动你的球是一个精灵的位置点.....
I am considering that you have taken your ball as a sprite. so in touchesBegan you will get the touch location and then you can use that location points in CCMoveTo action to move your ball which is a sprite.....
这篇关于查找球的目标位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文