XNA Windows游戏(4.0)到Xbox 360游戏(4.0)错误

时间:2014-05-08 14:00:21

标签: c# graphics xna runtime-error xbox

我在尝试将游戏从XNA移动到Xbox360时遇到了很大麻烦,我无法将其加载到Xbox中。我尝试了一块空白的石板。这有效,但在添加我自己的gam时,会出现以下错误:

No suitable graphics device exception

发生了什么事?

这是初始化和加载方法:

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

1 个答案:

答案 0 :(得分:1)

似乎在公共游戏1中你无法设置屏幕宽度或高度,并且会导致xbox版本出错。

所以我只是删除了代码,现在就可以了。

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

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

        //this.graphics.ApplyChanges();
    }