I was trying to use this well documented function with visual studios 2010 and xna 4.0 and get the error:
The type name FromFile does not exist in the type Microsoft.Xna.Framework.Graphics.Texture2D
With this code:
Texture2D tex1 = Texture2D.FromFile(device, "1.bmp");
Any idea why?
Texture2D.FromFileis a static method that returns you a texture. Yournewmakes C# look for a type calledTexture2D.FromFile(that is, a class insideTexture2DcalledFromFile).Drop the
new.EDIT: Seems 4.0 doesn’t have
Texture2D.FromFileat all. The closest match i see isTexture2D.FromStream, where you’d pass it an open stream to your file rather than its name.