mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Make Pong example "usable" on iOS
This commit is contained in:
parent
5ab36271c7
commit
9f4a0c3c4f
@ -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)
|
||||
{
|
||||
@ -151,6 +152,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)) ||
|
||||
((rightPaddleSpeed > 0.f) && (rightPaddle.getPosition().y + paddleSize.y / 2 < gameHeight - 5.f)))
|
||||
|
Loading…
Reference in New Issue
Block a user