Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试检测两个物体的碰撞。这种碰撞有不止一个选择,所以我想知道是否有任何方法可以声明半径CGPoint或类似的东西。
CGPoint
这是一个简单的方法来测试一个点是否在一个圆圈中:
-(bool)pointInCircle_circleCenter:(CGPoint)circleCenter circleRadius:(float)radius testPoint:(CGPoint)point{ float distance = (circleCenter.x-point.x) * 2 + (circleCenter.y-point.y) * 2; return distance <= radius * 2; }