【问题标题】:XNA Windows Game (4.0) to Xbox 360 Game(4.0) ErrorsXNA Windows 游戏 (4.0) 到 Xbox 360 游戏(4.0) 错误
【发布时间】:2014-05-09 22:14:09
【问题描述】:

我在尝试将我的游戏从 XNA 移动到 Xbox360 时遇到了很大的麻烦,并且我无法将其加载到 Xbox。我尝试了一张白纸。那行得通,但是在添加我自己的游戏时,会发生以下错误:

发生了什么?

这是初始化和加载方法:

    protected override void Initialize()
    {
        (Lots of Lists)
        Blocks = new List<Block>();

        (Lots of Char Maping)
        char[,] Level1 = {{'.','.','.','.','.','.','.', ect...


        Levels.Add(Level1);
        Levels.Add(Level2);
        Levels.Add(Level3);
        Levels.Add(Level4);
        Levels.Add(Level5);
        Levels.Add(Level6);
        Levels.Add(Level7);

        currentLevel = 0;
        Time = 0;
        deathCount = 0;

        offset = new Vector2(ScreenWidth / 2, ScreenHight - 300);

        base.Initialize();
    }

    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
        font = Content.Load<SpriteFont>("Font");
        font1 = Content.Load<SpriteFont>("Font");
        Texture2D ballSprite = Content.Load<Texture2D>("Person");
        rocketTexture = Content.Load<Texture2D>("Rocket");
        rocketDown = Content.Load<Texture2D>("MissileDown");
        rocketUp = Content.Load<Texture2D>("MissileUp");
        rocketLeft = Content.Load<Texture2D>("MissileLeft");
        rocketRight = Content.Load<Texture2D>("MissileRight");
        Green = Content.Load<Texture2D>("Green Block");
        player = new Player(ballSprite, Vector2.Zero, 6.0f, new Rectangle(0, 0, tileWidth, tileHeight));
        movingPlatform = new MovingPlatform(ballSprite, Vector2.Zero, 3.0f, 1);
        launcher = new Launcher(Green, Vector2.Zero, 0, Green);
        launcher.Load();
        camera = new Camera(GraphicsDevice.Viewport);
        collision = new Collision_Manager();
        collision.Initialize(this);
        LoadLevel(currentLevel);
        SoundManager.Initialize(Content);

        Texture2D IdleingRight = Content.Load<Texture2D>("Animation/IdleRight");
        IdleRight = Content.Load<Texture2D>("Animation/IdleRight");
        IdleLeft = Content.Load<Texture2D>("Animation/IdleLeft");
        InAirRight = Content.Load<Texture2D>("Animation/InAirRight");
        InAirLeft = Content.Load<Texture2D>("Animation/InAirLeft");
        animation.Add(new AnimationStrip("Idle", IdleingRight, 100, 1));
        Texture2D RunningRight = Content.Load<Texture2D>("Animation/RunRight");
        animation.Add(new AnimationStrip("RunRight", RunningRight, 55, 10));
        Texture2D RunningLeft = Content.Load<Texture2D>("Animation/RunLeft");
        animation.Add(new AnimationStrip("RunLeft", RunningLeft, 55, 10));
        Texture2D JumpingLeft = Content.Load<Texture2D>("Animation/JumpLeft");
        animation.Add(new AnimationStrip("JumpLeft", JumpingLeft, 25, 5));
        Texture2D JumpingRight = Content.Load<Texture2D>("Animation/JumpRight");
        animation.Add(new AnimationStrip("JumpRight", JumpingRight, 25, 5));
    }

【问题讨论】:

  • 你能分享一下“初始化”和“加载”方法吗?

标签: c# graphics xna runtime-error xbox


【解决方案1】:

好像在公共Game1中不能设置屏幕的宽度或高度,会导致xbox版本出错。

所以我只是删除了代码,它现在可以工作了。

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

        //this.graphics.PreferredBackBufferWidth = ScreenWidth;
       // this.graphics.PreferredBackBufferHeight = ScreenHight;

        //this.graphics.ApplyChanges();
    }

【讨论】:

  • 如果你不想修改你的代码,你可以使用 #if (!XBOX) ... #endif 这样屏幕的宽度和高度只有在不在 xbox 项目中时才设置:)
  • 这就是我所做的谢谢你的建议。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-01-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多