initializing mapDisplayDevice from outside game.cs

Jan 7, 2012 at 4:08 PM


Please bear with me i have only been playing with programming since xmas so please excuse the noob questions and not being able to explain myself correctly.

1st a little about me, i have never been one for learning from reading in life i have always learnt by just getting on and doing it.

I have always wanted to make simple games and decided to teach myself using the web, i started by looking at the xna platformer tutorial then the game managment tuts.

I managed to add lives and other bits like getting killed by a tile to the platform game sample (although it need put it in the right place as it resets upon starting a new level) i then found a sample with both of the projects integrated together and managed to make 90% of the 1st level of manic miner (i just need to make some tiles vanish when standing on them i managed to do the travelator tiles ect.)

I soon realised that using the ms sample i will struggle to keep tabs on the characters used for tile identification ect so when i was browsing the xna forum i saw TileD mentioned and thought a map editor would be great to use.

I made a new game management sample and with in 20 mins had it loading my tmx map no prob.

So i started to search on how to use it and came across this site saw the xTile demo with animated tiles and thought great this is so much better that TileD so decided to use this format as it seems far superior to the others.

Now here lies my problem as i am new to this i am struggling with drawing the map

All the samples i can find just make a new project and use the main game file to do everything i have a totally different structure as it will have option menu ect.. and my level initializing is all done in my level/gamescreen files.

My gamescreen calls the level class and constructs the level (im sure you are familer with how there platform sample works) and  i am struggling with the

mapDisplayDevice = new XnaDisplayDevice(this.Content, this.GraphicsDevice); part.

I have added Game to my class constructor ? ( class Level : Game) so i think should pick up the graphic manger for my game ?

But all i get is

The GraphicsDevice must not be null when creating new resources Parameter name: graphicsDevice

I am stumped with this as the documentation for xTile barely  exists and i have nobody to ask general programming questions too .

Im sure there is a simple fix i just need to inherit the right properties (if thats what its called) i just dont know who to ask / what to reasearch.!124&parid=root

here is my source code if anyone want to take a look and point me in the right direction also the compiled game i did with the platform sample


I hope one of you can spare me some time.






Jan 9, 2012 at 9:26 PM

I don't have time to download your project but it sounds to me like you have some code running in the wrong sequence. Try single stepping into the code to see what is being called when and then move your code around to run in the right sequence.

Jan 11, 2012 at 1:10 PM

Thx for the reply im sure its in the wrong place too.

Im working my way through other tutorials so hopefully i will be able to sort this soon as i learn more