与动画绘制顶点的多边形

问题描述:

第一关:我有一个问题创建在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 );
}