问题
In my future game(in SpriteKit), I need to draw circle-like shapes. I use CGMutablePathRef
and SKShapeNode
for drawing itself.
On touchesEnded
I need to check if the user did close the circle or if there is a gap between start and end touches.
(Strictly saying, it can be not only the right circle, I need to detect any closed shape, e.g. loop...)
How can I do this checking?
回答1:
- Store the touches locations (points) in an array:
[yourArray addObject:[NSValue valueWithCGPoint:yourPoint]];
- Make a rect (size? your choice! the smaller it is, the more precise) around the first point in the array (first touch location).
- Control if the rect also contains the last point in the array (last touch location).
- If so, then close your path.
来源:https://stackoverflow.com/questions/29366828/detect-that-skshapednode-is-closed