I am a beginner programmer who knows basics of java and C# and now am working with a fun and educational project with few friends on XNA. My goal here is to gain more understanding and start implementing OOP with comfort and as a natural part of OOP programming. Therefore I'm in a spot where I want to create Sprite classes to use in my main code to call those sprites into my application. I have had several problems so I would love to gain a certain ground to be certain that if things that I at the moment know are correct or not. So I would be very glad if you could confirm or disprove my understanding thusfar. Also I would like to mention that I have read quite alot of the tutorials but getting bits and pieces from everything so heres my understanding of what I have gathered without knowing if what I have gathered is correct.
So to begin.
When I make my XNA game project I have
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
I guess the GraphicsDeviceManager implements my graphic settings from my computer. Does the "This" in method arguments can be changed to anything and if then for what reason?
Moving on we have the Initialize method
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
I'm quite lost here. I know i can create my new objects there but im kind of clueless about the logic behind it. Short and logical explenation would be of great use here.
Next we have the LoadContent method.
Basically in LoadContent method I can load items from my content that I have added previously to GameContent in my case and then assign those items to certain objects?
Next thing that I dont understand fully is the line:
spriteBatch = new SpriteBatch(GraphicsDevice);
Next theres the Update method.
My questin here is that how many times per second update method runs aprox and where does this number come from?
If I would get answers to those questions then I think I understand that part of the section fully.
Moving on to Classes.
Lets say I make a new class called "Sprite".
Would love to have a confirmation or you know..the opposite of that word to my statements.
When I create a new Class then does classes in XNA behave the same way as for example in Java. So that at first i create all of the neccesary class variables that i need to use on that class( For example Vector2D as its location and Texture2D as its texture ). Next I would create the constructor but as far as i have seen from examples then Constructor in XNA is basically the LoadContent method? In where i give my previously declared variables their values. One thing I cant understand fully there is the cariable ContentManager which I apparantly need to use in the method.
Next having created the new class I would have to create a Draw method for the class right? In which I use theSpriteBatch.Draw(given texture, given position, given color ).
Having created the class I now turn towards my main Game1.cs in my case.
In the start of the program @ public class Game1 I declare that im going to use for example
Sprite man;
Then towards the initialize method ( as said before I'm not totally sure why ) I create the object called man.
man = new Sprite();
// what else can I do in this method with my new sprite?
Next we have the LoadContent method in main hwere i just have to call my given sprite's LoadContent method like this :
man.LoadContent(this.Content, "Man" ) // given that my mans sprite name was Man.png
Now that I have loded the content, all for me to do is Draw it right?
For that in my main Game1.cs class, I turn to the Draw method and just type out :
spriteBatch.Begin(); man.Draw(this.spriteBatch); spriteBatch.End(); // Again.. what is up with the spriteBatches?
I know this is a reaaaly beginner and noobish thread, but there arent really good tutorials online and I still have like a week at least til my book arrives.
If anyone would be awesome enough to help, I would greatly appriciate it!
Cheers
MheQ

New Topic/Question
Reply


MultiQuote




|