You are currently viewing the BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
Alright I'm having a bit of a problem on the pong game... I think this might be a silly error on my part, but I thought I'd check here to see if anyone else has had this problem:
I have coded the pong game all the way up to the top of page 38,I am supposed to see the space background drawn on my screen but I get an error that says:
Quote:
quote:Error - The type or namespace name 'PongGame' could not be found (are you missing a using directive or an assembly reference?
I have checked and I'm pretty sure the code is the same as the code I have downloaded. I still think this is something simple. If you would like me to post all the code I have entered I can do so. Thanks!
It might be the namimg convention of one of your .cs files. I think by default, you should have a file called Game1.cs(which includes your Update, Draw, Initialize methods, etc...). If so, rename it to PongGame.cs and see if that works. Or, you can just replace PongGame with Game1 on that line with the error.
It looks like you haven't created an object of type SpriteBatch yet. You are trying to call class SpriteBatch's methods using the class itself, but you cant. You have to create an object of type SpriteBatch to access the Begin(), Draw(), and End() methods. A class like a blueprint of what an object is supposed to do/contain.
To create an object from the SpriteBatch class:
SpriteBatch anyVariableName = new SpriteBatch(graphics.GraphicsDevice);
anyVariableName(the newly created object) is now an object of type SpriteBatch. Now the object can access SpriteBatch's(the class) methods.
You might want to look at a simple XNA program to understand its structure, and its 4 major methods(Initialize, LoadGraphicsContent, Update, and Draw).