I am trying to create an iPhone game with fairly large levels. Hard coding the platforms and physics objects is very time consuming. I have seen some people have made their own parsers for svg files to use in box2D, and Riq is selling levelSVG but it is a little pricey for me at the moment, and I only need basic features. Is there a tutorial on how to code a parser available online?
svgparser is a pull-based parser for SVG 1.1 Full data format without heap allocations.
Scalable Vector Graphics (SVG) are an XML-based markup language for describing two-dimensional based vector graphics.
Google Chrome, Firefox, IE, Opera, and every popular browser has the capacity to render SVG images. SVG files are also supported in basic text editors and high-end Graphics editors like CorelDRAW.
Have you taken a look at SVGQuartzRenderer? It is designed to render SVG files in Quartz, so I imagine you might be able to pull out the SVG parsing code from this. It's opensource, MIT license.
I don't know about any tutorials but its fairly easy to do this using an XML parsing library. In my project I use MiniDOM to load an svg file and then I convert the elements into objects in the box2d word. The only thing that I had to do manually was the parsing of the path element.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With