Reputation: 11
I'm using the tutorial Introduction to Programming Through Game Development Using Microsoft XNA Game Studio. I'm having trouble in the section about adding resources to a project.
I copied the instructions fairly well from what I can tell, except for changing the name of the picture - Still I get 3 errors being screen saying various names don't exist in the current context. How can I resolve these?
Upvotes: 0
Views: 2788
Reputation: 518
Both your texture and your rectangle are defined, initialized and disposed in your Init-Method. They are not accessible outside of that method. What you have to do is either pass them as method-parameters (not possible in in the Drawing-Method of XNA) or to make them "more public" and define them outside of your Init-Method:
private Texture2D starPic600Texture;
private Rectangle starPic600Rect;
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
starPic600Rect = new Rectangle(30,20,600,600);
starPic600Texture = this.Content.Load<Texture2D>("starPic600");
}
PS: Next time add your code-samples to your Question as code
instead of Pictures. This would make it a Little bit easier to copy-paste and addapt your samples.
Upvotes: 1