diff --git a/examples/pong/Pong.cpp b/examples/pong/Pong.cpp index f643ca4d..5cd4afa6 100644 --- a/examples/pong/Pong.cpp +++ b/examples/pong/Pong.cpp @@ -111,7 +111,8 @@ int main() } // Space key pressed: play - if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Space)) + if (((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Space)) || + (event.type == sf::Event::TouchBegan)) { if (!isPlaying) { @@ -150,6 +151,12 @@ int main() { leftPaddle.move(0.f, paddleSpeed * deltaTime); } + + if (sf::Touch::isDown(0)) + { + sf::Vector2i pos = sf::Touch::getPosition(0, window); + leftPaddle.setPosition(0.f, pos.y); + } // Move the computer's paddle if (((rightPaddleSpeed < 0.f) && (rightPaddle.getPosition().y - paddleSize.y / 2 > 5.f)) ||