2013-10-09 12 views
0

저는 XNA/Monogame에서 타워 디펜스 게임을 프로그래밍 중이고이 예외 "FileNotFoundException"이 발생할 때까지 잘하고있었습니다 (나는 이것들 중 하나를 얻었을 때 휴식을 취하고 계속할 때 작동하지 않습니다). 새로운 이미지를 추가 할 수 없다고합니다. 나는 그것들을 content 폴더에 넣고 rootdirectory는 Content로 설정한다. 오래된 이미지는 작동하지만 새로운 이미지는 작동하지 않습니다. 여기 내 내용은 Game1.cs이야 (이Monogame/XNA에서 내 텍스처를 찾을 수없는 이유는 무엇입니까?

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 Microsoft.Xna.Framework.Net; 
using Microsoft.Xna.Framework.Storage; 
using Microsoft.Xna.Framework.Input.Touch; 
using System.Diagnostics; 

namespace KillTheBugs2 
{ 
    /// <summary> 
    /// This is the main type for your game 
    /// </summary> 
    public class Game1 : Microsoft.Xna.Framework.Game 
    { 
     public Texture2D background; 
     public GameTime gameTime; 
     public Vector2 p; 
     Level level = new Level(); 
     public Player player; 
     public Ant ant1; 

     SpriteBatch _spriteBatch; 
     public GraphicsDeviceManager _graphics; 


     public Game1() 
     { 

      _graphics = new GraphicsDeviceManager(this); 

      _graphics.PreferredBackBufferWidth = 2000; 
      //This is wierd i will have to replace 32 with the size in pixels of 1 tile for some reason 
      _graphics.PreferredBackBufferHeight = 32 + 2500; 
      _graphics.ApplyChanges(); 
      IsMouseVisible = true; 
     } 

     /// <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() 
     { 

      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() 
     { 
      _spriteBatch = new SpriteBatch(GraphicsDevice); 
      Content.RootDirectory = "Content"; 
//background, ant, and blueberry bush wont load 
      background = Content.Load<Texture2D>("background"); 

      Texture2D AntTexture = Content.Load<Texture2D>("ant"); 
      ant1 = new Ant(AntTexture, Vector2.Zero, 100, 10, 0.5f); 
      Texture2D BlueberryBushTexture = Content.Load<Texture2D>("blueberrybush"); 
      player = new Player(level, BlueberryBushTexture); 




      // 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) 
     { 
      ant1.Update(gameTime); 
      List<Bug> bugs = new List<Bug>(); 
      bugs.Add(ant1); 

      player.Update(gameTime, bugs); 

      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); 


      // TODO: Add your drawing code here 
      _spriteBatch.Begin(); 
      level.Draw(_spriteBatch, ref background); 
      ant1.Draw(_spriteBatch); 
      player.Draw(_spriteBatch); 
      _spriteBatch.End(); 

      base.Draw(gameTime); 
     } 
    } 
} 
+1

새 이미지도 속성에 내용으로 표시되어 있습니까? – user2737037

답변

2

마크 새로운 이미지에 Build ActionContent으로 프로젝트에 추가 자사의 지저분한 (오류가 loadcontent 기능에서 어떤 일이 일어나고 그래서 비 텍스트 게임 프로그래밍 내 첫 번째 시간)입니다 일반적으로 오른쪽에있는 이미지의 속성 메뉴

+0

어디로 내용을 변경합니까? – Detinator10

+0

나는 그것을 바꿨습니다. – Detinator10

+0

고맙습니다. 신속하게 대응 – Detinator10