Saturday, October 9, 2010

Input System: Part 3 Keys and Buttons

Due to the extremely easy nature of this part of the tutorial there will not be much in terms of explanations. This part is going to cover key presses, button presses, key down and button down methods that we will add into our input class. First were going to make our prototypes, all these methods return bool so we can easily use them with an if state. Note the red underline is because they don't return anything which is required for non-void functions. Also click on the pictures if you can't read them.


Simply enough return if the key is down for the key down method. And in the key pressed return if our previous states key is up and our current state key is down.




We do the same comparison with our buttons except that we need to use the playerindex to get which game pad state it will use to check by converting the playerindex into an int then its the same as before.


Now to use this in any class in your game simply do the following. 


Thats it for this part of the tutorial next time I will cover triggers. If you have any questions ask them in the comments.

No comments:

Post a Comment