存储载体XNA动画 [英] Storing vector XNA Animations
问题描述
我正在XNA C#,当我来到这个问题,我需要存储易于编辑动画数据,这样我的游戏将能够渲染和播放。
I'm working on XNA C# when I came upon this problem where I need to store easily editable animation data such that my game will be able to render and play it.
这件事情是这样的:
我有纹理从(0,0)在整个屏幕飞往(800600)个像素。这将持续5秒。
I have a texture flying across the screen from (0,0) to (800,600) pixels. This will last 5s.
我怎样重新present它的数据,并把它写这样的游戏能够跨pret和做必要的绘图
和更新
方法。这是确定的,如果我需要做一些大量的编码。
How do I represent it in data and also write it such that the game is able to interpret and do the necessary in the Draw
and Update
methods. It's OK if I need to do some extensive coding.
推荐答案
一个简单的领域特定语言可以帮助;创建一个AnimationDirector类中,将跨preT从动画脚本中的语句,并做相应的工作中吸取
和更新
。在DSL本身可以像
A simple domain specific language could help; create an AnimationDirector class that would interpret the statements from the animation script and do the appropriate work during Draw
and Update
. The DSL itself could be as simple as
texture 0,0; 800,600; 5.0
这将创建纹理
(0,0)有质感的对象,它在5秒内移动(800600),然后摧毁它。
which will create an object with texture texture
at (0,0) and move it to (800,600) over a 5 second period, and then destroy it.
如果你想要的东西多一点有用的,
If you want something a little more useful,
create x texture 0,0
over 5.0 move x 800,600
destroy x
这将让你获得更多的创造性,扩大动漫的可能性(如添加旋转等,如果你渴望这样)。
which will let you get more creative, and expand the possibilities of animation (such as adding rotation, etc. if you desire such).
现在,当你需要运行一个动画,只是通过适当的资源名导演,让它从那里办事。或者,您可以创建某种AnimatedEntity的是指一个特定的脚本,并调用AnimationDirector本身绘图
和更新
;这取决于你怎么做你的引擎,到目前为止,这可能是更贴合它的设计。
Now, when you need to run an animation, just pass the appropriate resource name to the director, and let it handle things from there. Alternatively, you could create some kind of AnimatedEntity which refers to a particular script, and calls the AnimationDirector itself for Draw
and Update
; depending on how you've done your engine so far, this might be more fitting to its design.
这篇关于存储载体XNA动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!