Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

C# XNA Problem with drawing a texture with a rectangle

$
0
0
Hello!
I'm trying to draw a background in one of my menus(which I have done the same way before) and it just doesn't work.
I've tried to restart Visual studio without help.

In my class, I have created these:
Texture BackgroundTexture;
Rectangle BackgroundRectangle;



In LoadContent:
BackgroundTexture = Content.Load<Texture2D>("Inventory/InventoryBackground");
BackgroundRectangle = new Rectangle(0, 0, ScreenWidth, 432);



In my draw:
spriteBatch.Draw(BackgroundTexture, BackgroundRectangle, Color.White);



Now, I'm getting these errors:

Error 1:
The best overloaded method match for 'Microsoft.Xna.Framework.Graphics.SpriteBatch.Draw(Microsoft.Xna.Framework.Graphics.Texture2D, Microsoft.Xna.Framework.Rectangle, Microsoft.Xna.Framework.Color)' has some invalid arguments'

Error 2:
Argument 1: cannot convert from 'Microsoft.Xna.Framework.Graphics.Texture' to 'Microsoft.Xna.Framework.Graphics.Texture2D'

I have no idea what's wrong since it should work! Thanks in advance

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>