Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6
This is the forum to discuss the Wrox book Professional XNA Game Programming: For Xbox 360 and Windows by Benjamin Nitschke; ISBN: 9780470126776
Welcome to the p2p.wrox.com Forums.

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 .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 7th, 2008, 03:34 PM
Authorized User
 
Join Date: Jul 2006
Location: , , .
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ironchef
Default Pong probs --- Help...

Im really getting aggrivated at this computer... Whenever i go to build my game file, it says SpaceBakground file cannot be located. Ive placed the .dll in the content file, changed the Asset name and gotten the syntax correct. Ive even copied the code straight from the source code. Why isnt it working? here's the code I have(check the source code file for full code since I ended up copying and pasting):


protected override void LoadGraphicsContent(bool loadAllContent){
    if (loadAllContent){
    // Create sprite batch
    spriteBatch = new SpriteBatch(graphics.GraphicsDevice);

    // Load all our content
    backgroundTexture = content.Load<Texture2D>
            ("SpaceBackground");
    menuTexture = content.Load<Texture2D>("PongMenu");
    gameTexture = content.Load<Texture2D>("PongGame");
    audioEngine = new AudioEngine("PongSound.xgs");
    waveBank = new WaveBank(audioEngine, "Wave Bank.xwb");
        if (waveBank != null)
            soundBank = new SoundBank(audioEngine, "Sound
                    Bank.xsb");
    } // if
    base.LoadGraphicsContent(loadAllContent);
} // LoadGraphicsContent(loadAllContent)

IronChef - http://www.freewebs.com/cool_recipes
__________________
<b>IronChef</b> - http://www.freewebs.com/cool_recipes
  #2 (permalink)  
Old January 8th, 2008, 03:20 AM
Registered User
 
Join Date: Jan 2008
Location: binghamton, ny, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to firefoxmsp
Default

yeah, thank god someone else is having this problem. i have been struggling with this as well. i'm still waiting for someone to answer my post from a couple days ago.



  #3 (permalink)  
Old January 18th, 2008, 05:12 AM
Wrox Author
 
Join Date: May 2007
Location: Hannover, , Germany.
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to abi.exdream.com
Default

Hi ironchef,

does not look like your source code is wrong, but my guess is that there is no content file named "SpaceBackground" in the root directory (you can verify that by searching for a SpaceBackground.xnb file in the root directory of your output folder (probably \bin\Debug or \bin\x86\Debug).

If you have a content directory and have not redirected the root of the content loading directory (which would be a feature of XNA 2.0) the content manager will search in the application root directory, but not in the \Content directory, where your file might be located.

Alternatively if you have problems with content files you can also load the Textures directly via Texture2D.LoadFromFile(filename), then use a .dds file, which must obviously exist at the filename path too, but it is easier to check if this works than going though the content pipeline.

Hope this helps, if not please zip up your project and attach it here or email it to me (abi@exdream.com) so I can take a look.
Ben

http://abi.exdream.com
  #4 (permalink)  
Old January 19th, 2008, 07:36 PM
Registered User
 
Join Date: Jan 2008
Location: binghamton, ny, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to firefoxmsp
Default

so i added the SpaceBackground.xnb to the solution explorer. now i get no errors but debugger (ContentLoadException) still points to:

 backgroundTexture = content.Load<Texture2D>("SpaceBackground");

josh

  #5 (permalink)  
Old January 6th, 2009, 02:50 AM
Registered User
 
Join Date: Jan 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

in the constructor of the class just include following
Code:
Content.RootDirectory = "Content";
i guess the code is prety self explanatory.
  #6 (permalink)  
Old February 8th, 2009, 12:31 PM
Registered User
 
Join Date: Feb 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi all ...

Sorry for not knowing how to starting a new thread ... related to Pong ...

I have error with sourceRect.Width and sourceRect.Height not defined in RenderSprite method (on page 38 of the book). "Width" and "Height" seems not to be passed for each of the menu texture from the testMenuSprites on page 36.

Is there a declare statement somewhere that I have missed?

Thanks,


"Error 1 'System.Nullable<Microsoft.Xna.Framework.Rectangle >' does not contain a definition for 'Width' and no extension method 'Width' accepting a first argument of type 'System.Nullable<Microsoft.Xna.Framework.Rectangle >' could be found (are you missing a using directive or an assembly reference?) C:\Users\Tung\Documents\Visual Studio 2008\Projects\WindowsGame1\WindowsGame1\Game1.cs 187 84 WindowsGame1"
  #7 (permalink)  
Old February 21st, 2009, 04:12 PM
Friend of Wrox
Points: 894, Level: 11
Points: 894, Level: 11 Points: 894, Level: 11 Points: 894, Level: 11
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: London, , United Kingdom.
Posts: 166
Thanks: 2
Thanked 33 Times in 33 Posts
Default

Hi tkn_one,

As the paragraph above the RenderSprite code says, sourceRect is of type Nullable Rectangle, not a normal Rectangle, i.e. it could be null. This measn you cannot call Width directly from it. Instead you have to use the Value property (defined in the Nullable type) to get the actual rectangle if there is one. SO you would say something like:
sourceRect.Value.Width

Aside from that the DrawSprites method in the book is using the Width and Height of the sprite.rect, not the sourceRect, which is simply passed along to the spriteBatch.Draw method. So make sure you aren't getting the two mixed up.
Hope this helps
Phil

P.S. to start a new thread, go the main forum page for the book, and press the blue "New Thread" button just above the table of threads.
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pong... cshmny BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 0 October 1st, 2008 10:47 PM
Error Pong? bxrtuff24 BOOK: Professional XNA Programming 2nd Edition ISBN: 978-0-470-26128-6 0 September 28th, 2008 11:33 AM
Xbox 360 Game (2.0) - Pong darktatami BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 1 January 18th, 2008 05:26 AM
Pong Game Help -XM- BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 4 June 20th, 2007 03:23 PM
Chapter 2 pong menu problem alexmbr BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 8 May 25th, 2007 11:37 PM



All times are GMT -4. The time now is 03:40 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.