如何将 Ruby 嵌入到 XNA 引擎中?
我想知道是否可以将 Ruby 作为脚本语言嵌入到 Microsoft XNA 中,以及最好的方法是什么。 我正在寻找类似于 Xnua 的东西,除了 Ruby。
我偶然发现了 Ruby.NET 和 IronRuby,两者似乎都处于非常早期的阶段,所以我不确定它们的可用性如何。 此外,我不确定它们是否适用于 Xbox 360。这个主题位于 XNA例如,论坛 说 IronPython 无法工作。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
虽然它不是 Ruby 并且这是一个老问题,但我想向您介绍我一直在构建的新脚本引擎。 它基本上可以在任何有 .Net 框架的地方运行,包括在 XNA 下的 Xbox360 上。 它不使用 Reflection.Emit,因此它可以在其他语言无法使用的地方工作。 它也是完全托管的代码,因此没有像 Lua 那样的 P/Invokes。
您可以从我的博客获取更多信息,并可以在此演示页面
它几乎已经准备好进行 beta 测试,但在 beta 测试之后它将成为一个商业许可的组件
Although it's not Ruby and this is an old question, I'd like to enlighten you to a new scripting engine I've been building. It will run basically anywhere there is a .Net framework, including on the Xbox360 under XNA. It does not make use of Reflection.Emit, so it works where other languages do not. It also is completely managed code, so no P/Invokes either like Lua.
You can get more information from my blog and can try it out at this demo page
It's almost ready for beta testing, but after beta testing it will be a commercially licensed component
IronRuby 和 IronPython 不适用于 Xbox 360,因为它们基于 DLR(动态语言Runtime)并且 DLR 大量使用 System.Reflection.Emit 目前在 Xbox 360 .Net Framework(Compact .Net Framework 的修改版本)上不可用的类型。
不幸的是,至于做到这一点的最佳方法,这取决于游戏的其余部分。 在 XNA 程序的上下文中评估 IronRuby 脚本的工作相当简单,请查看此 博客文章。 除此之外,您还希望向脚本公开一些有趣的对象,这完全取决于游戏代码/设计的其余部分。 您可以查看Unity 脚本文档来了解要公开哪些类型和命令。
IronRuby and IronPython do not work on the Xbox 360 because they are based on the DLR (Dynamic Language Runtime) and the DLR makes heavy use of System.Reflection.Emit types which are not currently available on the Xbox 360 .Net Framework (a modified version of the Compact .Net Framework).
As to the best way to do that, unfortunately that depends on the rest of your game. The work to enable IronRuby scripts to be evaluated in the context of your XNA program is fairly easy, check out this blog post for example. Beyond that you'd want to expose some interesting objects to your scripts and that's the bit that's entirely down to the rest of your game code/design. You could have a look at the scripting docs for Unity to get an idea of what types and commands to expose.
几乎可以肯定,IronRuby 无法在 Xbox 上运行,但如果您只想为 Windows 开发 XNA 游戏,那么您应该能够以与任何其他应用程序相同的方式使用它。
我真的无法告诉你如何你会这样做,只是这应该是可能的。
It's almost guaranteed that IronRuby won't work on the Xbox, but if you just want to develop an XNA game for Windows, then you should be able to use it in the same way as for any other application.
I can't really tell you how you would go about doing that, just that it should be possible.
虽然我同意 Leaf Garland 的观点,但让我提供一个替代方案:
游戏的“首选”脚本语言是 Lua。 例如,《孤岛危机》和《孤岛惊魂》游戏就大量使用了 LUA。 浏览维基百科,查看使用它的著名游戏列表。
就与 XNA 一起使用而言,自从我开始爱好 XNA 开发以来,我只触及了表面,但我所知道的是,您不能直接在 XNA 中使用 LUA。 这是因为 LUA 是用 C++ 构建的(非托管),因此您将无法将其部署到 XBOX360。
有一个正在开发的项目正在构建 Lua 的 XNA 版本,位于 http://www.xnua.com/。 它也是一个免费产品,源代码也可供下载。
如果游戏行业认为 LUA 对于 AAA 商业游戏来说足够好,我个人也会遵循这个方向(因为他们在该领域比我有更多的经验)
While I agree with Leaf Garland's observations, let me offer you an alternative:
The "preferred" scripting language for games is Lua. For example the game Crysis and Far Cry uses LUA extensively. Flick over at wikipedia for a list of notable games that uses it.
In terms of using that with XNA, i've only scratched the surface since I just started myself with hobby XNA development, but what I do know is that you cannot use LUA directly in XNA. This is because LUA is built in C++ (unmanaged) and therefore you will not be able to deploy that to your XBOX360.
There is a project under development that is building an XNA version of lua at http://www.xnua.com/. It is also a free product and the source code is also available for download.
If the gaming industry belives that LUA is good enough for AAA commercial games, I would personally follow that direction as well (on the basis that they have way way more experience in that area than I do)
为什么PC端开发不用Ruby,360用Lua?
编辑:也许这个会有用。
Why not use Ruby for PC development and Lua for 360?
EDIT: maybe this will be useful.