开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜