AnimatedSprite issues

Sorry if this is a dumb question but when I use an animated sprite and try to draw it with spriteBatch.Draw(animatedSprite); I get the error that it cannot convert an animated sprite to a texture2D which I get but this is how it says to set it up in the monogamy extended wiki

Any help??
Thanks so much!

1 Like

It sounds like you might need to include the namespace at the top of your file like this:

using MonoGame.Extended.Sprites;

The reason is that the Draw method is implemented as an extension method on the SpriteBatch. Depending on what version of Extended you’re referencing (1.1 on NuGet or 2.0 in the develop branch), the signature of the method may be different.

In the older versions you’d call it like this:

spriteBatch.Begin();
spriteBatch.Draw(sprite);
spriteBatch.End();

In the newer versions you’d call it like this:

spriteBatch.Begin();
spriteBatch.Draw(sprite, position, rotation, scale);
spriteBatch.End();

We’ve decoupled the sprites transform from the sprite itself.

1 Like

That is exactly what happened, I was still using the much longer overload of sprite batch instead of the one that actually takes a sprite :-/

Will future builds include a layer depth in the method or is there a more efficient/smarter way to draw depth?

Thanks so much for the help, everything is animating perfectly now

I think you can control the Depth on the Sprite class itself.

1 Like