I am making a game for the Windows Phone using XNA framework C#.
The main player in the game has to shoot. I have a bullet class, but how do you instantiate that bullet everytime the user clicks on the screen?
The bullet class basically draws itself and has a function called “Shoot”, this is used for the bullet to move in the direction of the player.
I am a noob at c# xD
A common method is in your game loop add in a check for the screen being touched and take action if it is.
For XNA, on the Game class (which I think is called
Game1by default) create a field to store whether the screen was touched on the previous Loop:This is to prevent multiple bullets being created on a single touch (unless that is what you want).
Then in the
Updatemethod of the Game class check to see if the screen is currently being touched and take action: