开发者

Combining Windows Forms and XNA, but lacks "Game" instance

开发者 https://www.devze.com 2023-01-22 18:11 出处:网络
I am currently working on a Map Editor for my 3D game, but I am having some problems getting the using Microsoft.Xna.Framework.Game included.

I am currently working on a Map Editor for my 3D game, but I am having some problems getting the using Microsoft.Xna.Framework.Game included.

My 3D engine is stored in a library, and the constructor for it needs the Game instan开发者_StackOverflow社区ce and a GraphicsDevice. The GraphicsDevice is not a problem since i used some example from App Hub (link text), but using the "Game" is not included in it. Does anyone know how I would fix this? Thanks :)


Pretty much the entire point of the WinForms sample is to remove the use of Game (and the Microsoft.Xna.Framework.Game assembly). The Game class does things that you probably do not want to have happen within your editor.

I would recommend modifying your 3D engine so that it does not require an instance of the Game class, in order to be created.

What are you using from Game, anyway? A ContentManager, perhaps? Just pass that in directly.

But if you really must reference the Game class, add a reference to the Microsoft.Xna.Framework.Game assembly to your project. Do this by right clicking the project in the solution explorer, selecting Add Reference and finding it in the list of .NET assemblies. Make sure you get correct version.


I too am writing a 3D engine in XNA, called 'Vanquish'

Now that I've seen your constructor, you need to remove the Game variable from this. Create a public static variable called Instance in your Engine. Then, in your constructor add the following:

Instance = this;

From your WinForm application, whenever you need to use Game you can use engine.Instance.

0

精彩评论

暂无评论...
验证码 换一张
取 消