1
\$\begingroup\$

i started using the software tiled and it very simple to create an image and object positions over there. I am using the library XNA and i would like to load the image and the objects into my code, how can i do it? Will it be easier to save the image alone and the objects locations alone? Using XML/text file/in code values?

I found this topic: http://nerdculture.org/2009/07/14/tiled-maps-for-xna-full-support-for-the-tiled-map-xml-specification/ but that is a code that he made? Is there a library that does that? Second, i saw that he draw each tile alone, is there a way to draw the whole image? (will it make it faster?) Do you recommend to use what he posted?

Thank you for your help :)

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

It seems you may have misunderstood the purpose of Tiled or tilemapping in general, so maybe I could clarify a bit for you.

In simple terms, a tilemap is an array values that you use to construct your stage from an image (the tileset). It basically tells your code which part of the image to draw on the game screen. This way, you can reutilize your assets and construct vast stages using only a small texture.

From what I'm seeing, you're suggesting saving the level image you build in Tiled and then using it on XNA, and that's against the whole purpose of using a tiled-based implementation in your game.

Drawing each tile individually is many times faster than pre-rendering the stage and drawing it as a single image, saves you a lot of memory, disk space, and allows you to have better control over what to draw. It's an extremely efficient and useful technique if used properly.

The correct way of implementing Tiled would be to create a parser for the file format you choose to export your maps in (usually the .tmx extension which is a XML format) and then reading the values from the files to your code using an XML Serializer or reading the values manually, storing them in a class, and then using that as a basis for your game logic and for drawing the stage.

If you feel you can't do that on your own, you could use one of the free libraries. I used to play around with this one befored I made my own implementation:

https://bitbucket.org/vinull/xtiled

Although, I feel you could learn from the experience and should try making your own implementation. I suggest you study a bit about the theory behind the Tilemapping technique before going deep into the coding part itself. Maybe this tutorial can help:

http://xnaresources.com/default.asp?page=Tutorial:TileEngineSeries:1

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .