【发布时间】:2020-05-14 14:06:34
【问题描述】:
我是 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