views:

25

answers:

0

Hi, I am working on an Animation class for XNA. I decided to try using extension methods for SpriteBatch to add Draw methods that can draw an AnimatedSprite.

AnimatedSprite contains a list of Sprite objects, and a Sprite object has a Texture2D image. I created a static Extensions class that contains different overloads of the Draw method.

Here's one such method (I assume the problem is similar for all the functions):

    public static void Draw(this SpriteBatch b, AnimatedSprite sprite, Vector2 position, Color color)
    {
        b.Draw(sprite.CurrentSprite.Image, position, color);
    }

I get a ArrayTypeMismatchException when I run my project. I am not sure what is causing it because sprite.CurrentSprite.Image is a Texture2D.

Hopefully someone will be able to help me understand what is causing this problem and a potential fix.

Thanks!