Find destination position of ball

跟風遠走 提交于 2019-12-13 10:29:31

问题


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);

回答1:


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.....



来源:https://stackoverflow.com/questions/7159785/find-destination-position-of-ball

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!