2D C# XNA 游戏中的动画

发布于 2024-08-07 02:41:15 字数 186 浏览 1 评论 0原文

我想使用 XNA 在 C# 中创建 2d 游戏。火柴人应该可以佩戴不同的武器,如手枪、手榴弹或火箭发射器。那些火柴人还应该能够做其他事情,比如喝一瓶啤酒之类的。那么你如何创建和存储这些动画(喝一瓶啤酒、走路、扔手榴弹)以及你如何告诉他们如何握住武器(手枪:在手中,手榴弹:在手中,但将手臂放在身后,火箭发射器:在肩膀上)?最好的(简单且可扩展的)方法是什么?

I want to create a 2d game in C# using XNA. There should be stickmen who can wear different weapons like a pistol, a grenade or a rocket launcher. And those stickman also should be able to do other things, like drink a bottle of beer and stuff.. So how do you create and store these animations (drink a bottle of beer, walk, throw a grenade) and how can you tell them how to hold a weapon (pistol: in the hand, grenade: in the hand, but holding the arm behind them, rocket launcher: on the shoulder)? What's the best (simple and extensible) approach to this?

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

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

发布评论

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

评论(3

笑着哭最痛 2024-08-14 02:41:15

对于火柴人来说,我想到的是直接渲染骨骼的骨骼动画。与精灵相比,此类矢量图形的缩放效果非常好。骨骼动画存储具有长度和角度的骨骼树,并在预定义的关键帧之间进行插值。这样做的优点是,您可以轻松地将一些简单的物理和逆运动学与动画融合在一起(看看 Jakobsen 优秀的 Verlet 动力学论文)用于容纳武器、啤酒罐和壁架等。这是相当先进的东西,比 3D 图形容易得多,但它仍然需要你很长时间来设计和制作实施。

For stickmen, comes to my mind, skeletal animations with directly rendered bones. Such vector graphics would scale very well compared to sprites. Skeletal animation stores a tree of bones with lengths and angles, and interpolates between predefined keyframes. The advantage of this is that you can easily incorporate some simple physics and inverse kinematics that blend with the animations (take a look at Jakobsen excellent Verlet dynamics paper) for holding weapons, beer cans and mantling ledges, etc. This is fairly advanced stuff, much easier than 3D graphics, but it will still take you a long time to design and implement.

魔法唧唧 2024-08-14 02:41:15

使用 SpriteBatch 合成精灵(给英雄一把剑等)时可以提供帮助的一件事是某些 Draw 方法重载的 Origin 参数。它允许您围绕左上角以外的其他位置旋转,并且在定位不同大小的精灵时也可以提供帮助。由于原点是在源纹理比例中指定的,因此如果以不同比例绘制精灵,则任何计算都将是有效事件。

One thing that can help when compositing sprites (giving a hero a sword, etc) using SpriteBatch is the Origin argument on some of the Draw method overloads. It allows you to rotate around something other than the top left corner and can also help when positioning sprites that are of differing sizes. Since the Origin is specified in source texture scale, any calculations will be valid event if the sprites are drawn at a different scale.

江城子 2024-08-14 02:41:15

你问的是一个相当广泛的问题。您可能想查看 XNA Game Studio 附带的 2D 平台游戏示例。这可以帮助你开始。

What you're asking is a fairly broad question. You might want to have a look at the 2D Platformer sample that comes with XNA Game Studio. That can get you started.

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