找到球的目标位置
如何根据接触角度移动球并在球接触到墙壁时使球反射?
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);
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你已经把你的球当作精灵了。所以在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.....