4 Replies - 646 Views - Last Post: 24 October 2016 - 08:18 AM

#1 Braber01  Icon User is offline

  • D.I.C Regular

Reputation: 5
  • View blog
  • Posts: 294
  • Joined: 29-November 08

Exception in LoadContent() GraphicsDevice component Not Found

Posted 24 October 2016 - 07:22 AM

Trying to add additional features to a Breakout tutorial, decided I was trying to over complicate things and I should just go for a basic game first, and then once I get that working save a backup of the project then start adding new stuff, I guess I'm too eager to learn.


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;

using Breakout.GameScreens;
using XRpgLib;

namespace Breakout {
	//<summary>
	//This is the main type for your game
	//</summary>
	public class Game1 : Microsoft.Xna.Framework.Game {
		GraphicsDeviceManager graphics;
		public SpriteBatch spriteBatch;

		
		//GameStateManager stateManager;
		public TitleScreen titleScreen;
		public GamePlayScreen gamePlayScreen;
		
		Rectangle screenRectangle;
		Paddle paddle;
		//Rectangle screenRectangle;
		int bricksWide = 10;
		int bricksHigh = 5;
		Texture2D brickImage;
		Brick[,] bricks;
		Ball ball;
		const int STARTING_LIVES = 5;
		int livesRemaining;

		public Rectangle ScreenRectangle {
			get {
				return screenRectangle;
			}

			set {
				this.screenRectangle = value;
			}
		}

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

			//graphics = new GraphicsDeviceManager(game);
			graphics.PreferredBackBufferWidth = 750;
			graphics.PreferredBackBufferHeight = 600;
			//stateManager = new GameStateManager(this);
			//Components.Add(stateManager);
			//titleScreen = new TitleScreen(this, stateManager);
			//gamePlayScreen = new GamePlayScreen(this, stateManager);
			//TODO: Prefect titleScreenLayout
			//stateManager.ChangeState(titleScreen);
			//stateManager.ChangeState(gamePlayScreen);
		
			ScreenRectangle = new Rectangle(
				0, 0,
				graphics.PreferredBackBufferWidth,
				graphics.PreferredBackBufferHeight);


			Texture2D tempTexture = Content.Load<Texture2D>("paddle");
			paddle = new Paddle(tempTexture, ScreenRectangle);

			tempTexture = Content.Load<Texture2D>("ball");
			ball = new Ball(tempTexture, ScreenRectangle);

			brickImage = Content.Load<Texture2D>("brick");
			StartGame();

		}

		private void StartGame() {
			livesRemaining = STARTING_LIVES;
			paddle.SetInStartPosition();
			ball.SetInStartPosision(paddle.GetBounds());
			bricks = new Brick[bricksWide, bricksHigh];

			for (int y = 0; y < bricksHigh; y++) {
				Color tint = Color.White;
				switch (y) {
					case 0:
						tint = Color.Orange;
						break;
					case 1:
						tint = Color.Red;
						break;
					case 2:
						tint = Color.Yellow;
						break;
					case 3:
						tint = Color.Blue;
						break;
				}//End Switch

				for (int x = 0; x < bricksWide; x++) {
					bricks[x, y] = new Brick(
						brickImage,
						new Rectangle(
							x * brickImage.Width,
							y * brickImage.Height,
							brickImage.Width,
							brickImage.Height),
						tint);
				}//end for X
			} // end for Y
		}//StartGAme


		//<summary>
		//Allows the game to perform any initialization it needs to before starting to run.
		//This is where it can query for any required services and load any non-graphic
		//related content.  Calling base.Initialize will enumerate through any components
		//and initialize them as well.
		//</summary>
		protected override void Initialize() {
			// TODO: Add your initialization logic here

			base.Initialize();
		}

		//<summary>
		//LoadContent will be called once per game and is the place to load
		//all of your content.
		//</summary>
		protected override void LoadContent() {
			// Create a new SpriteBatch, which can be used to draw textures.
			spriteBatch = new SpriteBatch(GraphicsDevice);

			// TODO: use this.Content to load your game content here
		}

		//<summary>
		//UnloadContent will be called once per game and is the place to unload
		//all content.
		//</summary>
		protected override void UnloadContent() {
			// TODO: Unload any non ContentManager content here
		}

		//<summary>
		//Allows the game to run logic such as updating the world,
		//checking for collisions, gathering input, and playing audio.
		//</summary>
		//<param name="gameTime">Provides a snapshot of timing values.</param>
		protected override void Update(GameTime gameTime) {
			// Allows the game to exit
			if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
				this.Exit();
			paddle.Update();
			ball.Update();
			foreach (Brick brick in bricks)
				brick.CheckCollision(ball);
			ball.PaddleCollision(paddle.GetBounds());

			if (ball.OffBottom() && livesRemaining != 0) {
				livesRemaining -= 1;
				ball.SetInStartPosision(ScreenRectangle);
			}
			if (ball.OffBottom() && livesRemaining == 0) {
				StartGame();
			}
			//base.Update(gameTime);

			// TODO: Add your update logic here
			base.Update(gameTime);
		}

		//<summary>
		//This is called when the game should draw itself.
		//</summary>
		//<param name="gameTime">Provides a snapshot of timing values.</param>
		protected override void Draw(GameTime gameTime) {
			GraphicsDevice.Clear(Color.CornflowerBlue);
			spriteBatch.Begin();
			//base.Draw(gameTime);
			paddle.Draw(spriteBatch);
			foreach (Brick brick in bricks)
				brick.Draw(spriteBatch);
			ball.Draw(spriteBatch);
			spriteBatch.End();

			// TODO: Add your drawing code here

			/*foreach(Brick brick in bricks) {
				brick.Draw(spriteBatch);
			}*/
			base.Draw(gameTime);
		}
	}
}



Not a clue what's going on, and still kind of confused.

Is This A Good Question/Topic? 0
  • +

Replies To: Exception in LoadContent() GraphicsDevice component Not Found

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13395
  • View blog
  • Posts: 53,461
  • Joined: 12-June 08

Re: Exception in LoadContent() GraphicsDevice component Not Found

Posted 24 October 2016 - 08:00 AM

Please copy/paste the entire exception message.
Was This Post Helpful? 0
  • +
  • -

#3 Braber01  Icon User is offline

  • D.I.C Regular

Reputation: 5
  • View blog
  • Posts: 294
  • Joined: 29-November 08

Re: Exception in LoadContent() GraphicsDevice component Not Found

Posted 24 October 2016 - 08:12 AM

ContentLoadException Was Unhandled Error Loading "paddle" GraphicsDevice component Not Found
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13395
  • View blog
  • Posts: 53,461
  • Joined: 12-June 08

Re: Exception in LoadContent() GraphicsDevice component Not Found

Posted 24 October 2016 - 08:14 AM

Does it give a line number? Maybe line 070? If so then you don't have a texture called 'paddle' in the project.
Was This Post Helpful? 0
  • +
  • -

#5 Braber01  Icon User is offline

  • D.I.C Regular

Reputation: 5
  • View blog
  • Posts: 294
  • Joined: 29-November 08

Re: Exception in LoadContent() GraphicsDevice component Not Found

Posted 24 October 2016 - 08:18 AM

No it doesn't give a line number at all.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1