I'm following a tutorial from XNA GPA, but in my project, none of the sprites are loading. I've followed all of the instructions exactly, and the code works as expected when I copy it from my project into the example project that he provides.

Here's my Game.cs

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Tutorial

    public class Game : Microsoft.Xna.Framework.Game
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        Paddle paddle;
        Rectangle screenRectangle;

        public Game()
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            screenRectangle = new Rectangle(0, 0, graphics.PreferredBackBufferWidth,

        protected override void Initialize()
            // TODO: Add your initialization logic here


        protected override void LoadContent()
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            Texture2D tempTexture = Content.Load<Texture2D>("paddle");
            paddle = new Paddle(tempTexture, screenRectangle);
            // TODO: use this.Content to load your game content here

        protected override void UnloadContent()
            // TODO: Unload any non ContentManager content here

        protected override void Update(GameTime gameTime)
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)

            // TODO: Add your update logic here



        protected override void Draw(GameTime gameTime)

            // TODO: Add your drawing code here



Any help would be greatly appreciated, thank you.

  • \$\begingroup\$ So it runs and nothing happens (no errors)? You get a CornflowerBlue screen? \$\endgroup\$ – Felsir Jul 26 '15 at 14:55
  • \$\begingroup\$ Yes, that's correct. \$\endgroup\$ – Robert Woods Jul 26 '15 at 15:08
  • \$\begingroup\$ Set the paddle position to be in the middle of the screen \$\endgroup\$ – dimitris93 Jul 26 '15 at 15:31
  • \$\begingroup\$ Yeah, modify the Paddle.Draw function to draw a texture at coordinates you know are inside the viewport. \$\endgroup\$ – Felsir Jul 26 '15 at 18:27
  • \$\begingroup\$ Here's my SetInStartPosition method private void SetInStartPosition() { position.X = (screenBounds.Width - texture.Width) / 2; position.Y = screenBounds.Width - texture.Width - 5; } and my Draw() method public void Draw(SpriteBatch spriteBatch) { spriteBatch.Draw(texture, position, Color.White); } SetInStartPosition() is called in the constructor for paddle so surely this should work? \$\endgroup\$ – Robert Woods Jul 26 '15 at 18:41

A possible problem is in your SetInStartPosition(). For setting the Y position it should be position.Y = screenBounds.Height - texture.Height... not screenBounds.Width - texture.Width...

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.