Animating a polygon drawn with vertices

Firstly: I still had the question of Creating a two-dimensional polygon in XNA , but I answered myself after a day of disappointment with research and testing. There you can find the code that I have right now. So, here is my next question, since I can't do anything about it. How to animate a VertexPositionColor[] .

0
source share
1 answer

To animate VertexPositionColor [], all you really need to do is change the elements of the array correctly and then use the new values ​​in the 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
source

Source: https://habr.com/ru/post/896227/


All Articles