Issue: A SKShapeNode
sometimes doesn't draw the entire path. If it's moving each frame some frames it doesn't draw. In my real case scenario I'm using a very complex 10+ sided shape but for this demo I'm just doing a triangle. See screenshots for example (http://imgur.com/a/50mHA).
Code: See this in action by adding this to the basic template, or any scene, and move the mouse (finger) around. Some shapes show this glitching more than others but if you move around enough you'll see it on every shape.
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
CGPoint location = [[touches anyObject] locationInNode:self];
[self enumerateChildNodesWithName:@"path" usingBlock:^(SKNode *node, BOOL *stop) {
[node removeFromParent];
}];
CGMutablePathRef p = CGPathCreateMutable();
CGPathMoveToPoint(p, NULL, location.x-80, location.y-130);
CGPathAddLineToPoint(p, NULL, location.x+80, location.y);
CGPathAddLineToPoint(p, NULL, location.x-80, location.y+130);
CGPathCloseSubpath(p);
SKShapeNode *shape = [SKShapeNode node];
shape.name = @"path";
shape.path = p;
shape.fillColor = [UIColor redColor];
[self addChild:shape];
}
Any idea what's going on?
Edit: I wanted to add that the overall effect I'm trying to accomplish is dynamic lighting in a scene with physics bodies and a player (light source). I have used the information from http://ncase.me/sight-and-light/ to create a polygon. However as the player runs through the level, 99% of the time it works fine, except for that 1% where the shape glitches and doesn't draw completely. Which is what I'm showing in the example here.