Hi Guys,
maybe someone of you has some idea how to do this.
I want to insert an SVG image via <img src...> into an HTML website and then grab all elements of it in Firefox. I can't information about that. Mostly the examples are using SVGs created during runtime
Replies
edit: whoops sorry didn't read the entire question somehow.
Look into the contentDocument command
elements = []
element = object.getElements();
or something?
SVG is a form of XML, you can open them up in notepad to get at the individual data elements.
Maybe this link will help you with putting a SVG in your HTML.
Looks like the <embed> tag works fine for a .SVG file.
You can also open up the SVG in notepad and copy everything below the <?xml... tag and paste it directly into your HTML anywhere in between the <body> tags and it'll show up on the page as well. So copy/paste everything from the <svg... blah blah start tag to the </svg> end tag.
EDIT:
Oh beat to it, well maybe something like this:
http://svgkit.sourceforge.net/
or this:
http://raphaeljs.com/
might help.
EDIT2:
or this:
http://code.google.com/p/svgweb/
or this:
http://processingjs.org/ EDIT3: - this looks promising.
That would give me a "level editor" without a lot work and i would have just to save the picture out of Inkscape to tweak the level. Sure i could paste the "source" of the SVG into the HTML but i would like to make it "right" and "clean".
http://jumpnslide.tumblr.com/post/2557920924/how-to-use-inkscape-as-a-game-development-tool
http://duriansoftware.com/joe/Using-Inkscape-as-a-map-editor.html
Once the level is done you convert it to something easier to use by your game like a JSON file or something.
http://stackoverflow.com/questions/2010892/storing-objects-in-html5-localstorage
http://24ways.org/2010/html5-local-storage
EDIT:
or maybe just access from the server/webhost it like everything else, images etc...?
or like this:
http://falcon80.com/JSON/AccessingFromJS.html
Either way I think you're pretty brave to make a game in HTML5.
If it were me, I'd be sticking to Flash for now. Admittedly I've been looking at JavaScript and HTML5 stuff for the past week or so... new tech is so shiny and attractive :poly136:
Good luck!
http://www.json.org/js.html
I'll post my progress. If i can't find something it seems i have to use Internet Explorer, wait for the next Firefox, paste the SVG Code directly into my JS code or place the game-elements by hand. :,(
Unless you want to use the SVG as art all you seem to need to get from it are object IDs, positions, and orientations, right? Then you use that data in your game's logic like in spawnEnemies() and loadLevel() methods for example, to place the proper game objects like enemies, and level sprites.
I must be missing some key point here since I don't know JavaScript. Sorry about that by the way, I'm probably giving bad advice...
I think you could frankenstein a script together that could write your final JavaScript for you given both the input of your level JSON and your game code. That way you wouldn't have to copy/paste manually during design iteration.