iDevGames Forums
Coloring game - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Coloring game (/thread-8387.html)



Coloring game - moharla - Dec 6, 2010 06:51 AM

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.


RE: Coloring game - skyhawk - Dec 6, 2010 12:45 PM

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?


RE: Coloring game - OneSadCookie - Dec 6, 2010 12:50 PM

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.


RE: Coloring game - SethWillits - Dec 6, 2010 03:03 PM

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.