Animating a polygon drawn with vertices

我的梦境 提交于 2019-12-25 01:43:23

问题


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[].


回答1:


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 );
}


来源:https://stackoverflow.com/questions/7258880/animating-a-polygon-drawn-with-vertices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!