Reputation: 23
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?
Upvotes: 2
Views: 811
Reputation: 86496
Texture2D.FromFile
is a static method that returns you a texture. Your new
makes C# look for a type called Texture2D.FromFile
(that is, a class inside Texture2D
called FromFile
).
Drop the new
.
EDIT: Seems 4.0 doesn't have Texture2D.FromFile
at all. The closest match i see is Texture2D.FromStream
, where you'd pass it an open stream to your file rather than its name.
Upvotes: 3