Texture loading, drawing is null.

Hello, I just picked C# about three days ago and I’m havin a blast learning it. But I’m getting this “tiny” issue over and over and over. Heres a screenshot of the relevant code, as you may notice it’s pretty much barebones to when you create a new project.

My starts texture it’s loading, as if I had set the wrong name or it wasn’t there at all while debugging Visual Studio would stop it, however as you might notice I added a null check and guess what, the null check is positive so nothing draws. Before the program was just stopping at that point.

Thanks for your time, also “fondo” is spanish for “background”.

— Nehemek —

Remove the Texture2D keyword in front of “fondo” from LoadContent method. You are hiding the global texture with a local variable. :slightly_smiling:

We’ve all done similar things, no matter how experienced we are.

General advice:

ALWAYS take a look at the VS warnings with wavy lines in your code (in this case the fondo variable at the top), because it gives you quite good clue about the problem.

For me its strange why there is no wavy line under the other fondo in your LoadContent method, indicating that your are hiding the global fondo…? Maybe only inherited, but hidden members are marked with this line…? :slightly_smiling:

Thank you guys :D! Yes, removing te Texture2D helped but there was another issue, I had to click build and then rebuild o.O.

Build only builds those files that have been changed. Rebuild builds all of them. I do not think you have found a bug in VS. :wink: