问题
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