Detect that SKShapedNode is closed

Yevgeniy Leychenko

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?

suyama
  1. Store the touches locations (points) in an array: [yourArray addObject:[NSValue valueWithCGPoint:yourPoint]];
  2. Make a rect (size? your choice! the smaller it is, the more precise) around the first point in the array (first touch location).
  3. Control if the rect also contains the last point in the array (last touch location).
  4. If so, then close your path.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事