与动画绘制顶点的多边形 [英] Animating a polygon drawn with vertices

查看:206
本文介绍了与动画绘制顶点的多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第一关:我有一个问题创建在XNA 二维多边形但我沮丧的研究和测试了一天之后回答了它自己。在那里,你可以找到code我现在。因此,这里是我的下一个问题,因为我无法找到任何关于它。我怎么一个动画 VertexPositionColor []

First off: I had another question Creating a 2D polygon in XNA but I answered it myself after a day of frustrating research and testing. There you can find the code I have right now. So here is my next question, as I can't find anything about it. How do I animate a VertexPositionColor[].

推荐答案

要动画一个VertexPositionColor [],你真正需要做的是适当地修改数组的元素,然后在DrawUserPrimitives使用新的值()调用

To animate a VertexPositionColor[], all you really need to do is modify the elements of the array appropriately and then use the new values in your DrawUserPrimitives() call.

例如,在你的游戏的更新方法:

For example, in the Update method of your game:

for ( int index = 0; index < vertices.Length; ++index )
{
    vertices[ index ].Color *= (float)System.Math.Sin( gameTime.ElapsedGameTime.Seconds / 60 );
}

这篇关于与动画绘制顶点的多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆