C++ Tastendruck nicht durchgängig?

1 Antwort

Zeig mal bitte deine Eventschleife

sf::Event event;

while (window.pollEvent(event)){ 
 if (event.type == sf::Event::Closed)

window.close();

if (event.type == sf::Event::KeyPressed) {

if (event.key.code == 71) {
square.move(sf::Vector2f(-10, 0));
}

if (event.key.code == 72) {
square.move(sf::Vector2f(10, 0));
}

if (event.key.code == 73) {
square.move(sf::Vector2f(0, -10));
}

if (event.key.code == 74) {
square.move(sf::Vector2f(0, 10));
}

if (event.key.code == 57) {
...Sprungparabel berechnen...
}
}
0
@TheMusicBoy

ich mache es immer so:

while (window.pollEvent(event))
{
   //das übliche, um das Fenster zu schließen
   if (sf::Keyboard::isKeyPressed(sf::Keyboard::A)
      object.move(v.x, v.y)
}
0

Was möchtest Du wissen?