Coloring game
I am looking at writing a coloring game which once if we click on the color and select an object in the graphic only the object gets colored, for ex: if I have a horse and i click on its tail only the tail gets colored.
However i am not able to get the exact co-ordinates or the object's area so that only that part gets colored.
Any help in this regard would be greatly appreciated.
However i am not able to get the exact co-ordinates or the object's area so that only that part gets colored.
Any help in this regard would be greatly appreciated.
Sounds like you're looking to do a simple flood fill on the area. That of course only works if all the white pixels are connected. Do you need something more elaborate?
I'd precalculate the areas (perhaps still using floodfill, or perhaps by having the artist draw masks in Illustrator). Floodfill at run-time will break when the kid colors everything black.
I would create all the art as bezier paths. You can use the paths to determine what the user touched, and filling a path with a color is simply changing the fill color of the path.
The only complicated part is getting from a file format containing the paths, to a CGPath or NS/UIBezierPath. An SVG file is an xml file containing vector paths which are apparently described in a way where it's really easy to build a CGPath or NS/UIBezierPath from them, and any self-respecting vector art application will have an SVG export feature. You could look there.
The only complicated part is getting from a file format containing the paths, to a CGPath or NS/UIBezierPath. An SVG file is an xml file containing vector paths which are apparently described in a way where it's really easy to build a CGPath or NS/UIBezierPath from them, and any self-respecting vector art application will have an SVG export feature. You could look there.

