Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - krej

Pages: [1]
1
Quote from: "Kingdom of Fish"
Or you can switch to using events.


I'd like to switch to events, but I tried that and there is only a small delay in shooting. Instead of it spamming nonstop, its *shoot shoot shoot* *slight delay* *shoot shoot shoot*

This is the code I have for events:

Code: [Select]

sf::Event Event;
while (App.GetEvent(Event)) {
  if ( Event.Key.Code == sf::Key::Space ) {
     sf::Sprite Missle(MissileImage);
     Missile.SetPosition(Player.GetPosition());
     Missile.SetRotation(Player.GetRotation());
     missiles.push_back(Missile);
  }
}

2
I'm trying to make a simple space invaders game, and I have this:

if ( App.GetInput().IsKeyDown(sf::Key::Space)) { /* shoot missile */ }

However, if you hold down space it spams the missiles. How do you get around this? I want it so that they have to press space each time they want to shoot a missile.

Pages: [1]
anything