• Recreated monogame project in XNA and it refuses to compile
    2 replies, posted
Firstly, I know there is a thread for help requests but I'd rather make this an individual thread which can be closed or ignore easily after being answered rather than spamming up the help thread. I followed this tutorial for the project I made and also used VS2013: [URL="http://blogs.msdn.com/b/tarawalker/archive/2012/12/04/windows-8-game-development-using-c-xna-and-monogame-3-0-building-a-shooter-game-walkthrough-part-1-overview-installation-monogame-3-0-project-creation.aspx"]>Click<[/URL] I'm completely aware that monogame is better than XNA since XNA was discontinued. However I ran into a rather serious bug playing back music files in Monogame, apparently the problem was fixed in the developer builds of Monogame, but myself and a few others still seem to be having the problem. So rather than continue on with the project without any sound support I decided to redo the tutorials using Visual Studio 2010 and XNA, with the intention of documenting any future changes so that when Monogame is usable again I can resume. Here's the main source files: [URL="http://pastebin.com/qEHgiH4i"]Animation.cs[/URL] [URL="http://pastebin.com/dnuT0D8n"]Game1.cs[/URL] [URL="http://pastebin.com/GQDqzAdV"]ParallaxingBackground.cs[/URL] [URL="http://pastebin.com/evPKih5D"]Player.cs[/URL] [URL="http://pastebin.com/aXqmDWMJ"]Program.cs[/URL] It seems to compile ok until it hits the player.cs files, at which point it gets to "PlayerAnimation.Position = Position;" where it crashes and returns "NullReferenceException was unhandled Object reference not set to an instance of an object." This problem only seems to happen in XNA (VS2010), but in Monogame (Vs2013) it doesn't happen at all and comparing them I can't find any code difference aside from the odd differences in formatting. I'm still coming to grips with programming and I find all of this extremely confusing I tried asking on stackoverflow and got my thread closed and linked to a "What is a NullReferenceException and how do I fix it?" Thread which I tried to look at but struggled to even understand it. As stuck as I am I really don't want to give up because I know this will put me off trying to program for a decent length of time Whilst it is asking a lot, I would appreciate if anyone could show me an actual fix instead of just linking me to a thread and leaving me to fix it myself. Any further details required feel free to ask.
Looks to me like you are never initializing your player.
How would I go about doing that? I may be wrong (my C# understanding is rather basic so I'm relying on that tutorial for a lot. As I said this is very confusing for me because I checked the code between the XNA and Monogame project and it is the same. So either there is some difference that I'm completely unaware of, or the problem is somehow triggered by using VS2010 (XNA) instead of VS2013 (Monogame). [editline]12th July 2014[/editline] Solved, thanks a lot! You were right when I rewrote the code I forgot the "player.Initialize(playerAnimation, playerPosition);" in the LoadContent method. I've been stressing over this for ages. THANKS A LOT!!!!
Sorry, you need to Log In to post a reply to this thread.