C# XNA: Use Custom Mouse Animated Cursor .ani

I am trying to use custom animated cursor in Xna game.

I tried to load the .ani cursor to content but it's wont build so i removed it and tried to use it from local disk . but its also wont to accept .ani format.

            using(System.IO.StreamReader stream = new System.IO.StreamReader(System.Environment.CurrentDirectory + "//Data//Cursor//Normal.ani"))
            {
                this.cursorTex = Texture2D.FromStream(this.GraphicsDevice, stream.BaseStream);
            }

but i got an exception says file format not accepted.

Upvotes: 0

Views: 256

Answers (1)

Mikiel
Mikiel

Reputation: 448

Texture2D.FromStream only supports .bmp, .gif, .jpg, .png, .tif and .dds file formats. According to the inline source documentation:

        /// Creates a Texture2D from a stream, supported formats bmp, gif, jpg, png, tif and dds (only for simple textures).
        /// May work with other formats, but will not work with tga files.

It seems like you also can't use the .ani format in a content project either. According to RB Whitaker these are the supported image file types for content projects:

.bmp, .dds, .dib, .hdr, .jpg, .pfm, .png, .ppm, .tga

It looks like you'll have to manually implement the mouse cursor animation using a spritesheet system.

Hope that helps.

Upvotes: 1

Related Questions