I'm working on developing a version of Sudoku as seen below...
The conventional method of testing for touches in a grid like version of sudoku is relatively easy. Grid Squares can be a series of Tile objects with their touch interface defined or using a bit of math and keeping track of touch points you can find out which tile has been touched.
My problem is that I need to dynamically generate cells out of these ring segments as the number of segments reflecting different sudoku puzzles.
One method I've found is to store paths and use method CGPathContainsPoint to test if a point is stored within the path...
Code:
CGMutablePathRef myPath = CGPathCreateMutable();
CGPathMoveToPoint ( myPath, NULL, top.x, top.y );
CGPathAddLineToPoint( myPath, NULL, bottomRight.x, bottomRight.y );
CGPathAddLineToPoint( myPath, NULL, bottomLeft.x, bottomLeft.y );
CGPathCloseSubpath( myPath );
bool pathContainsPoint = CGPathContainsPoint( myPath, NULL, myPoint, false );
NSLog( @"path %@ contain point", ( pathContainsPoint ? @"DOES" : @"does NOT" ));
I got this from
here.
This test could correlate to points generated using touch events.
However this seems quite over complex and has a couple of problems more that I'd have to work out. Has anyone got any experience with anything like this?
Problems:
1. Generating cells in the middle of these segments dynamically.
2. The fact that the arches are drawn from outside to the centre overlapping path areas would mean the outside arch contains all of the points of the inner arches so somehow I would need to subtract these paths or use some kind of layering.
Any ideas? Alternative solutions?
Thanks.