且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

存储载体XNA动画

更新时间:2023-12-06 13:29:22

一个简单的领域特定语言可以帮助;创建一个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.