从 DLL 绘制 XNA 文本

发布于 2024-07-23 07:40:43 字数 311 浏览 3 评论 0原文

我计划为 XNA 构建一个 2D 游戏库,我想要包含的组件之一是一个用于调试目的的简单文本抽屉。 现在,要使用 SpriteBatch 绘制文本,您需要一个 .spritefont 文件,这是一个 xml 格式文件,并且这些似乎需要编译到单独的文件夹中。 我不想将其与 dll 一起复制,所以这是我的问题: 我可以为 XNA 构建某种文本渲染器吗 答:不需要我携带带有 dll 的外部文件(如果你可以将精灵字体嵌入到 dll 中,那么就可以了)并且 B:不会强迫我重写大量使 SpriteBatch.DrawString 代码工作的底层代码(它是托管的 directx?xna 的不同部分?)。

I am planning on building a 2D game library for XNA, and one of the components I want to include is a simple text drawer for debug purposes. Now, to draw text with SpriteBatch you need a .spritefont file, which is an xml format file, and these seem to need to compile into a separate folder. I would prefer not to have to copy that around with the dll, so here is my question:
can i build some sort of text renderer for XNA that
A: does not require me to carry around external files with the dll (if you can embed the sprite font into a dll then that works) and
B: does not force me to rewrite a fair amount of underlying (is it managed directx? a different part of xna?) code that makes the SpriteBatch.DrawString code work.

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

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

发布评论

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

评论(2

夜未央樱花落 2024-07-30 07:40:43

您是否可以只要求将 SpriteFont 传递到您的库中,以便使用该库的任何人都必须提供该组件? 这似乎是最好的解决方案,因为这样他们就可以使用他们想要的任何字体。 或者您可以编写一个组件,根据给定的字体名称生成 spritefont xml 文件,因为它并不是那么复杂的文件。 忽略。 我忘记了 XNA 编译了它的资源。

Could you not just require that a SpriteFont be passed into your library, so that whoever is using the library has to supply that component? That would seem to be the best solution, since then they could use whatever font they wanted. Or you could write in a component that generates the spritefont xml file based on a given font name, because it's not all that complicated of a file. Disregard. I forgot that XNA compiles its resources.

醉生梦死 2024-07-30 07:40:43

您可以预编译该项目,然后获取 spritefont 的 xnb 文件。 然后将该文件作为内容文件添加到项目 Content 文件夹中。 然后它应该与库一起部署。 但是,您需要为您希望支持的每个平台(xbox360、windows、zune)构建单独的 xnb 文件并部署正确的文件。

或者为什么不创建一个 XNA 内容库项目呢?

You can precompile the project and then grab the xnb file for the spritefont. Then add the file to the project Content folder as a content file. It should then be deployed together with the library. However u will need to build a separate xnb file for each platform you wish to support (xbox360, windows, zune) and deploy the correct file.

Or why don't u just create a XNA Content Library project?

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