开发者

Animating a polygon drawn with vertices

开发者 https://www.devze.com 2023-04-01 11:11 出处:网络
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 nex

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 开发者_Go百科I animate a VertexPositionColor[].


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号