Search code examples
xnacollision-detectionscaletexture2ddownsize

Downsizing a Texture2D in XNA


I would like to downsize a Texture2D object to another Texture2D object in XNA.

The reason is to use the downsized object for pixel based collision detection.

Can this be done?


Solution

  • You should take a look at the per-pixel collision tutorial as well as the transformed per-pixel collision tutorial.

    Essentially, to do collision detection on a transformed texture (such as a scaled one like you want) you use a transformation matrix. It's not overly difficult and the tutorials give a good example. The tutorial doesn't scale but rotates, but comments are include in the source that show you where and how to do scaled as well.