Are you sure you don't have spriteBatch.Begin inside of the foreach by mistake?
This is what that excerpt of DrawSprites looks like on my side:
Code:
// Start rendering the sprites
spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.BackToFront, SaveStateMode.None);
// Render all sprites
foreach (SpriteToRender sprite in sprites)
{
spriteBatch.Draw(sprite.texture,
// Scale to fit resolution
new Rectangle(
sprite.rect.X * width / 1024,
sprite.rect.Y * height / 768,
sprite.rect.Width * width / 1024,
sprite.rect.Height * height / 768),
sprite.sourceRect,
sprite.color);
}
spriteBatch.End();
I too encountered the width/height thing, so I went and looked at the downloadable source code for the chapter 2 to see how they were set. (It later turned out that width and height are mentioned on page 58 in the Troubleshooting section.)
Another problem I just came across is that in the TestMenuSprites() listing on page 37, the testGame.RenderSprite(...) bits don't match up with the RenderSprite definition on page 40.
For example, page 37 says this:
Code:
testGame.RenderSprite(testGame.menuTexture,
512 - XnaPongLogoRect.Width / 2, 150,
XnaPongLogoRect);
But the downloadable code says this:
Code:
testGame.RenderSprite(testGame.menuTexture,
new Rectangle(512-XnaPongLogoRect.Width/2, 150,
XnaPongLogoRect.Width, XnaPongLogoRect.Height),
XnaPongLogoRect);
I'm not sure if we're meant to have figured that out on our own or what, but it contradicts the statement on page 41 that "... if you press F5 now, you can see the screen shown in Figure 2-5.".
Edit:
Ugh, so apparently the downloadable code for this book available here isn't even for XNA 2.0:
http://www.wrox.com/WileyCDA/WroxTit...load_code.html
You have to go to the author's personal website to get the correct code:
http://exdream.no-ip.info/blog/2008/...acingGame.aspx
This edition of XNA Programming seems to be a bit sloppy.