MonoGame项目运行时意外退出

问题描述 投票:0回答:1

我是MonoGame和C#的新手,所以我可能做了一些愚蠢的事情,但我无法找出我的项目有什么问题。

SharpEngine/SharpContext.cs:

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using SharpEngine.Utils;

namespace SharpEngine
{
    public class SharpContext : Game
    {
        public Logger logger;

        public GraphicsDeviceManager graphics;

        public SpriteBatch spriteBatch;

        public SharpContext()
        {
            logger = new Logger();

            graphics = new GraphicsDeviceManager(this);
        }

        protected override void Initialize()
        {
            logger.Log("Initializing...", true);

            Window.Title = "Sharp Engine";

            graphics.PreferredBackBufferWidth = 1280;
            graphics.PreferredBackBufferHeight = 720;
            graphics.ApplyChanges();

            Content.RootDirectory = "Content";

            base.Initialize();

            logger.Log("Initialized.", true);
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
        }

        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            spriteBatch.Begin();
            GraphicsDevice.Clear(Color.CornflowerBlue);
            base.Draw(gameTime);
            spriteBatch.End();
        }
    }
}

SharpGame/Main.cs:

using System;
using SharpEngine;

namespace SharpGame
{
    class Game1 : SharpContext
    {
        public static Game1 game1;
        public Game1() : base()
        {
            Program.game1 = this;
            game1 = this;
        }
    }
    class Program
    {
        public static Game1 game1;

        [STAThread]
        static void Main(string[] args)
        {
            using (Game1 game = new Game1())
            {
                game.logger.enableVerbose();
                game.logger.Log("Starting up...", true);
                game.logger.Log("Calling SharpContext.Run()...", true);
                game.Run();
            }
        }
    }
}

当游戏运行时,唯一的输出是:

[ 9:56:13 AM Verbose Log       ]: Starting up...
[ 9:56:13 AM Verbose Log       ]: Calling SharpContext.Run()...

然后它立即退出

我不知道为什么会出现这种情况。

我使用的是Manjaro Linux。

如果需要更多的信息来帮助,就问吧,我会提供的。

c# .net .net-core monogame
1个回答
0
投票

更新:我使用的是Microsoft.Xna.Framework; ..:

我使用的是 MonoGame.Framework.Portable,这只是头。我觉得自己很笨。

© www.soinside.com 2019 - 2024. All rights reserved.