I managed to solve this problem by setting the path UIBezierPath, which draws a triangle as a property in the Triangle class. In the touchheBegan: method scene, I check to see if the touch is contained inside the Triangle property of touchableArea UIBezierPath.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint position = [touch locationInNode:self];
NSArray *nodes = [self nodesAtPoint:position];
for (TrianglePiece *triangle in nodes) {
if ([triangle isKindOfClass:[TrianglePiece class]]) {
position = [touch locationInNode:triangle];
if ([triangle.touchableArea containsPoint:position]) {
}
}
}
}
source
share