This project is read-only.

xTile Tutorial for XNA Game Studio 4.0

This is a short tutorial explaining how to get started with the xTile tiling engine using XNA Game Studio 4.0. By the end of this tutorial you should have a working XNA 4.0 game application for Windows featuring a parallax scrolling animated map.

Prerequisites

Steps

1. Start Visual Studio 2010 and create a new XNA Windows Game (4.0) project and name it xTileGame1.

 

2. Using the Solution Explorer panel, create a new solution folder named xTile directly under the solution. Also create a corresponding xTile folder on disk within the xTileGame1 solution folder. 

 

3. Copy the xTile.dll (PC version) and xTile.Pipeline.dll assemblies from the downloaded xTile Engine ZIP archive into the xTile solution folder created previously. Add the assemblies as existing items under the xTile folder in Solution Explorer. 


4. Add an xTile.dll reference to the xTileGame1 project. 


5. Add an xTile.Pipeline.dll reference to the xTileGame1Content content project of the xTileGame1 project (not the game project itself)


6. Add a tIDE map file and its associated tile sheet images in the xTileGame1Content content project. Create content folders as necessary to maintain relative path references from the map file to the tile sheet image sources. Ensure that the map file's Content Importer and Content Processor properties are set respectively to tIDE Map Importer and tIDE Map Processor. Also ensure that the Build Action property of the tile sheet image files referred by the map file is set to None to avoid conflicts with the map's content processor. 

 

7. Compile the project and verify that the tIDE map file is being correctly processed by the content pipeline. 

 

8. Access the code file Game1.cs and add the following using clauses for the xTile engine: 


9. Add member variables for an xTile map, display device and viewport: 


10. Within the Initialize() method, instantiate the map display device, load the map resources and set a display viewport: 


11. Within the LoadContent() method, load the map from the content pipeline: 


12. Within the Update(GameTime gameTime) method, update the map for tile animation and update the viewport for level scrolling: 


13. Within the Draw(GameTime gameTime) method, render the map visually using the display device and viewport: 


14. Compile and run the xTileGame1 project. 

 

Note for Visual Studio Express Users

Solution folders are not supported in the Express edition of Visual Studio. In this case, you may place the assemblies in project folders or simply opt out from adding them as project items.

Last edited Jan 17, 2013 at 9:53 AM by colinvella, version 4

Comments

vicki_dlam Apr 12, 2013 at 10:28 PM 
Hello,
I have a problem when read the map, i did exactly what you did and compile it, there doesn't have the line that read the map, just compile the tilesheets....Please help, thanks!

gladius2metal Jan 17, 2013 at 9:56 AM 
this post probably solves most problems: http://tide.codeplex.com/discussions/255146

duckiejune Jul 17, 2012 at 8:35 AM 
Can I ask how to resize the window? because after i compile and run it, I only saw half of the map.

jokopato Jul 10, 2012 at 8:55 AM 
i got this Error

Error 1 Error loading pipeline assembly "xTile.Pipeline, Version=2.0.4.0, Culture=neutral, PublicKeyToken=36a932edc483725e". xTileGame1


how to fix this one?

ArturoX Apr 14, 2012 at 8:57 PM 
Excellent aplication!! It worked perfectly!

Now, how do I manage the tiles generated? I mean, create collisions, movile platforms, etc.
Do you have a tutorial about how handle those generated sprites?

Thanks in advance!!

divined2004 Feb 9, 2012 at 9:34 AM 
I just downloaded the latest version tIDE (xTile204.zip). The problem is that when I try to import into Visual Studio 2010 (content of my game project), I get this error :

Error loading pipeline assembly "xTile.Pipeline, Version=2.0.4.0, Culture=neutral, PublicKeyToken=36a932edc483725e".

Is this some sort of bug or incompatibility? I`m using XNA 4.0 (Windows game 4.0).

Jay_Gaming Nov 8, 2011 at 8:40 PM 
Hello all,

After going to every step outlined above, i am getting this error

Error 1 Error loading pipeline assembly "xTile.Pipeline, Version=2.0.4.0, Culture=neutral, PublicKeyToken=36a932edc483725e". xTileGame1

Has anyone ever come across this before? i think this is coming from STEP.6 as i downloaded the tIDE application built my image saved the file and added it to my project, i am not sure if what i have done is correct if anyone can help me out i would be grateful, Thanks

Lanandor Aug 9, 2011 at 8:12 PM 
in step 6 you say:
Ensure that the map file's Content Importer and Content Processor properties are set respectively to tIDE Map Importer and tIDE Map Processor.
I don't have those listed in drop down list box. How do i add them?
tried looking in my C# and XNA reference books and could not find it
thanks

Dilli Apr 29, 2011 at 11:49 AM 
I've just tried the documentation with Visual Studio 2010 Express. Works flawlessy but you can't add folders directly under the solution.
I added the xTile folder in 'xTileGame1' instead.

colinvella Apr 22, 2011 at 3:08 PM 
Yes, it seems the latest update introduced a problem when a path contains spaces such as in the folder "Visual Studio 2010"

DarkTwister Apr 17, 2011 at 2:22 PM 
Hello.
I have a problem, I get this error:
"Error 1 Missing asset "C:\Users\DarkTwister\Documents\Visual%20Studio%202010\Projects\Ogicass\Ogicass\OgicassContent\TileSheets\Background01.png". C:\Users\DarkTwister\Documents\Visual Studio 2010\Projects\Ogicass\Ogicass\OgicassContent\Maps\Map01.tide Ogicass"
Do you have any idea why?
Best Regards
DarkTwister

Adderus Apr 8, 2011 at 4:51 PM 
The load content method should read:

protected override void LoadContent()
{

// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);

//Load xTile map from content pipeline
map = Content.Load<Map>("Maps\\Map01");

//Initialize xTile map resources
map.LoadTileSheets(mapDisplayDevice);
}

Otherwise this will cause a nullreference exception because it is trying to load a null map variable.