I am trying to create a simple application, really simple.
I don’t know why, but when I click the left arrow, or the right one, the texture doesn’t change it position.
I am sure I’m missing something, can’t figure what, gonna look stupid.
main file: http://paste.ubuntu.com/919662/
Character.cs: http://paste.ubuntu.com/919664/
Position.cs: http://paste.ubuntu.com/919665/
Thanks a lot.
UPDATED ANSWER:
The real culprit is:
KeyboardState Keyboard = new KeyboardState();
You cannot use ‘Keyboard’ as a variable name. It’s a class from XNA! You are redeclaring it. Hence, your key presses are no longer being detected! Use this instead:
And update your references
This answer is somewhat valid:
You are initializing Character
But then in your Update() method you do:
You are properly modifying the value of Pos in the Character class, but that is in no way associated with myTexture. In fact, you are not even drawing “Character” on the screen at all.
TL;DR: You are modyfing the “Character” class, but you are drawing myTexture. You are modify the coordinates on the object that holds myTexture, not Character.
Additionally, if you want to draw “Character” on screen, the best way would be just use Vector2D instead of your own Pos class.
One more thing:
In LoadContent you are doing
But the documentation clearly states:
/// LoadContent will be called once per game and is the place to load
/// all of your content.
That should get you started on how to fix it up. If you still have questions, just post a comment under my answer.