I'm building an app using spriteKit (objective-C), and I'm using intersectsNode to tell if a player-drawn line collides with letter tiles on the gameboard. I have another instance of intersectsNode in my program that is working fine, but for some reason this new scenario always returns false. I've checked the parameters, and the only thing spriteKit says is make sure they are both children of the same tree, which they definitely are (self). One is a SKSpriteNode, and the other is a SKShapeNode.
if (directionIsDecided == TRUE) {
for (letterTile in letterTileArray) {
if ([letterTile intersectsNode:selectorLine]) {
[lettersToBeCalculatedForPoints addObject:letterTile];
}
}
}
Hopefully I'm not overlooking something stupid... Any ideas what could cause this function to never return true?
*edit
Ok, I think it has something to do with how I'm drawing my line. I changed it up so it detects collision with the vowels that have been spawned on the board, each vowel being a child of letterTile, and now it tells me that ALL vowels are colliding with the selecorLine, even if it doesn't touch any of them.
This is how I created my selectorLine:
Implementation:
CGMutablePathRef pathToDraw;
SKShapeNode *selectorLine;
TouchesBegan:
UITouch* touch = [touches anyObject];
CGPoint positionInScene = [touch locationInNode:self];
pathToDraw = CGPathCreateMutable();
CGPathMoveToPoint(pathToDraw, NULL, positionInScene.x, positionInScene.y);
selectorLine = [SKShapeNode node];
selectorLine.path = pathToDraw;
selectorLine.strokeColor = [SKColor greenColor];
selectorLine.lineWidth = 10;
[self addChild:selectorLine];
selectorLine.zPosition = 101;
TouchesMoved:
UITouch* touch = [touches anyObject];
CGPoint positionInScene = [touch locationInNode:self];
CGPathAddLineToPoint(pathToDraw, NULL, positionInScene.x, positionInScene.y);
selectorLine.path = pathToDraw;
Any and all ideas are appreciated, thanks!