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 d开发者_开发知识库iffY = ballImg.position.y - tchLoc.y;
CGFloat angleRadian = atan2f(diffY, diffX);
float angleDegrees=CC_RADIANS_TO_DEGREES(angleRadian);
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.....
精彩评论