Visual Studio 2010 中 SL/XNA 解决方案的不同项目中应该包含哪些内容?

发布于 2024-12-13 08:53:10 字数 276 浏览 0 评论 0原文

在 Visual Studio 2010 中,我创建了一个新的 Windows Phone Silverlight 和 XNA 应用程序。它创建的解决方案包含 3 个项目:

  1. myProject
  2. myProjectLib
  3. myProjectLibContent

我可以理解像图片和纹理这样的内容应该放在 myProjectLibContent 中,但是 myProjectLib 呢,我应该放什么而不是放在 myProject 的文件夹中?

In Visual Studio 2010 I created a new Windows Phone Silverlight and XNA Application. The solution it created contained 3 projects:

  1. myProject
  2. myProjectLib
  3. myProjectLibContent

I can understand that content like pictures and textures, should go in myProjectLibContent, but what about myProjectLib, what should I put in there instead of in a folder in myProject?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蒗幽 2024-12-20 08:53:10

项目如此设置的原因只是 Visual Studio 和 XNA Game Studio 工作方式的一个怪癖。

因此,您从 myProject 开始,它是一个 Silverlight 项目。它与您创建的任何 Silverlight 项目相同 - 不同之处在于它还具有对 XNA 程序集的程序集引用,因此您可以在该项目中编写 XNA 代码,并且它可以正常编译。

现在,由于您正在使用 XNA,因此您可能想要使用 XNA 内容管道。因此,您也会在模板中获得一个 XNA Content Pipeline 项目 (myProjectLibContent)。

现在您所要做的就是构建这两个项目,对吧?错误的!

首先,XNA Content Pipeline 项目是一种特殊的项目。它无法自行构建 - 尝试一下 - 尝试右键单击该项目并选择“构建” - 该选项不存在。

XNA 内容管道项目只能从 XNA 项目构建。 Silverlight 项目不是 XNA 项目。 只有 XNA 项目才能拥有“内容引用” - XNA 项目将在其自己的构建过程中构建该内容引用。请注意,Silverlight 项目没有“内容引用”部分。

因此,XNA 库项目 myProjectLib 存在的唯一原因是充当 Silverlight 项目和内容项目之间的桥梁。 Silverlight 项目引用 XNA 库项目,后者又构建并包含内容项目。

这意味着您可以安全地忽略 XNA 库项目并将其留空。

Windows 上也是同样的情况。使用 XNA 的 WinForms 项目需要 XNA 库项目才能构建 XNA 内容项目。

The reason the projects are set up like that is simply a quirk of how Visual Studio and XNA Game Studio work.

So you start with myProject which is a Silverlight project. It's the same as any Silverlight project you'd create - except that it also has assembly references to the XNA assemblies so you can write XNA code within this project and it will compile just fine.

Now, because you're using XNA, you probably want to use the XNA content pipeline. So you get an XNA Content Pipeline project (myProjectLibContent) in the template as well.

Now all you have to do is build these two projects, right? Wrong!

First of all, an XNA Content Pipeline project is a special kind of project. It can't build itself - try it - try right-clicking the project and selecting "Build" - the option isn't there.

An XNA Content Pipeline project can only be built from an XNA project. The Silverlight project is not an XNA project. Only XNA projects can have "Content References" - which the XNA project will then build during its own build. Note the Silverlight project doesn't have a "Content References" section.

So the only reason that the XNA Library Project myProjectLib exists is to act as a bridge between the Silverlight project and the content project. The Silverlight project references the XNA Library project, which in turn builds and includes the content project.

This means that you can safely ignore the XNA Library project and leave it empty.

It's the same deal on Windows. A WinForms project that uses XNA needs an XNA Library project in order to build XNA content projects.

客…行舟 2024-12-20 08:53:10

Lib 是一个“图书馆”项目。通常在创建 XNA 游戏时不会创建一个,即使在 4.0 中也是如此。事实上,您不必将任何内容放入它为您创建的内容中。

通常,库是一个集中例程的存储,可用于任何游戏或任何您游戏类型的游戏(例如任何角色扮演游戏)。然后您可以从游戏基础项目库中更具体的实现中调用这些例程。

然而,这些都不是必需的,如果这是您的第一款游戏,我建议您完全忽略。将您的代码放在第一个项目中,将内容放在第三个项目中,然后就可以开始了!

Lib is a "Library" project. Usually one is not created when creating a XNA game, even in 4.0. In fact, you don't have to put anything in it in the one it created for you.

Typically, a Library is a storage of centralized routines one would use on any game or any game of your game's type (like any rpg). And then you would call those routines from the more specific implementations in the game's base project library.

However, none of that's required and if this is your first game, I'd recommend you ignore in entirely. Place your code in the first project, the content in the 3rd and go to town!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文