저는 Windows Phone 7 용 애완 동물 관리를위한 게임을 만들고 싶지만, 문제가있는 부엉이가 있는데 이것은 null 메소드를 가지고 있다고 말합니다.하지만 왜 내가 가지고 있는지 모르겠습니다. 게임의 각 주마다 열거 형. http://crystalnix.deviantart.com/art/XNa-Problem-396626207?ga_submit_new=10%253A1377747418이 방법은이 매개 변수에 대해 null을 허용하지 않습니다.
이 메인 파일입니다 : 여기
는 메시지의 사진입니다.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.Input.Touch;
using Microsoft.Xna.Framework.Media;
using Mochi_Mochi_Pets_Life.Script.Screen;
namespace Mochi_Mochi_Pets_Life
{
public class MainFile : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
ScreenStates screentState;
Rectangle TouchS_Y_X;
Logo logo;
Menu0 menu;
Choose_Pets choose_pets;
ScreenStates.CurrentGameState GameState;
public MainFile()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
Content.RootDirectory = "Script\\Screen";
choose_pets = new Choose_Pets();
this.screentState = new ScreenStates();
this.logo = new Logo(GraphicsDevice);
this.menu = new Menu0();
// Frame rate is 30 fps by default for Windows Phone.
TargetElapsedTime = TimeSpan.FromTicks(333333);
// Extend battery life under lock.
InactiveSleepTime = TimeSpan.FromSeconds(1);
GameState = ScreenStates.CurrentGameState.Logo;
}
protected override void Initialize()
{
choose_pets.Initialize_choosepets();
// TODO: Add your initialization logic here
base.Initialize();
}
protected override void LoadContent()
{
TouchS_Y_X = new Rectangle(0, 0, 1, 1);
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
if (GameState == ScreenStates.CurrentGameState.Logo)
this.logo.Load(this.Content, this.GraphicsDevice);
if (GameState == ScreenStates.CurrentGameState.Menu)
this.menu.Load_Menu(GraphicsDevice, Content);
if (logo.FadeOut_logo == true)
GameState = ScreenStates.CurrentGameState.Menu;
if (GameState == ScreenStates.CurrentGameState.CharactersChooser)
this.choose_pets.Load_ChoosePet(this.Content, this.GraphicsDevice);
// TODO: use this.Content to load your game content here
}
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
//this.logo.Unload_logo(Content);
}
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
if (GameState == ScreenStates.CurrentGameState.Logo)
logo.Update_logo(gameTime);
if (GameState == ScreenStates.CurrentGameState.CharactersChooser)
choose_pets.Update_petchoose(gameTime);
// TODO: Add your update logic here
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Black);
spriteBatch.Begin();
if (GameState == ScreenStates.CurrentGameState.Logo)
logo.Draw(spriteBatch);
if (logo.FadeOut_logo == true)
menu.Draw_Menu(spriteBatch);
if (GameState == ScreenStates.CurrentGameState.CharactersChooser)
choose_pets.Draw_petChoose(spriteBatch);
spriteBatch.End();
base.Draw(gameTime);
}
}
}
그리고이 사람은 나에게 문제
을 제공하는 메뉴입니다using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
namespace Mochi_Mochi_Pets_Life
{
class Menu0
{
Texture2D Text2D_Background;
Rectangle Rec_Background;
Texture2D ButtonText2DPlay;
Rectangle ButtonRecPlay;
public void Load_Menu(GraphicsDevice Graphics_Menu, ContentManager Content_Menu)
{
Content_Menu.RootDirectory = "Content";
Text2D_Background = Content_Menu.Load<Texture2D>("UI\\MenuBack");
Rec_Background = new Rectangle(0, 0, Graphics_Menu.Viewport.Width, Graphics_Menu.Viewport.Height);
ButtonText2DPlay = Content_Menu.Load<Texture2D>("UI\\Buttons\\New Games");
ButtonRecPlay = new Rectangle(Graphics_Menu.Viewport.Width, 400, 150, 40);
}
public void Draw_Menu(SpriteBatch Spritebatch_Menu)
{
Spritebatch_Menu.Draw(Text2D_Background, Rec_Background, Color.White);
Spritebatch_Menu.Draw(ButtonText2DPlay, ButtonRecPlay, Color.White);
}
}
}
좋아 어떤이가하는 것은 나의 로고 페이드 인 경우 == 홈페이지 마누하지만 결코 진실 게임 주 점프 텍스처 Text2D_Background는 항상 null 그래서,
은 그 시점에서 spritebatch null입니까? 그것이 – Jonesopolis
인 것처럼 보입니다. 그러나 그것이 내 Spritebatch를 가지고 있고, Graphicsdevice와 Contentmanager im dunno xD를 가지고 있다면 왜 null 이겠는가. – user2727653
나는 그것을 디버깅 할 수 있다고 생각한다. – Jonesopolis