Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say I have a rectangular Texture2D object in XNA, and I draw it on the screen. How can I animate it so it slowly changes to a trapezoid shape, and then to a pentagon, etc.

I have no idea what this technique is called, so I couldn't find anything on Google.

share|improve this question
How do you 'draw it on the screen' currently? If using a SpriteBatch, you will have to move to a real manual rendering. – jv42 Jun 8 '12 at 12:56
The technique is called interpolation. – doppelgreener Jun 8 '12 at 14:33
up vote 1 down vote accepted

Presumably you are using SpriteBatch. SpriteBatch is only capable of drawing rectangles. You need to go lower-level.

What you are looking for is how to draw 2D primitives.

I'll leave it as an exercise to search the web for an appropriate tutorial. But you will probably find yourself at least using the BasicEffect class and the GraphicsDevice.Draw*Primitives() method.

In fact, you probably want to look up how to use the method GraphicsDevice.DrawUserPrimitives<VertexPositionTexture>(). That is an ideal place to start.

I'm going to assume that you are good enough at coding to figure out how to modify the contents of your vertex array each frame in order to animate it. If you need a starting point, look up "lerping" ("linear interpolation"). Particularly the Vector3.Lerp method. MSDN is your friend.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.