I want to be able to have a sprite shoot in a game for WP7. What I have at the moment is that as long as the shoot button is held down the sprite constantly shoots. How do I sort it that only one bullet is shot from touching the button and not a stream of bullets is released? I want for the player to be able to shoot another bullet, they must tap the button again. This was taken from a DreamInCode tutorial on how to make an asteroids clone for PC.
foreach (TouchLocation location in TouchPanel.GetState())
{
if (shootKeyBounds.Contains((int)location.Position.X,
(int)location.Position.Y))
{
FireBullet();
}
}
The fire bullet method
private void FireBullet()
{
Sprite newBullet = new Sprite(bullet.Texture);
Vector2 velocity = new Vector2(
(float)Math.Cos(ship.Rotation - (float)MathHelper.PiOver2),
(float)Math.Sin(ship.Rotation - (float)MathHelper.PiOver2));
velocity.Normalize();
velocity *= 6.0f;
newBullet.Velocity = velocity;
newBullet.Position = ship.Position + newBullet.Velocity;
newBullet.Create();
bullets.Add(newBullet);
}