mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31: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)
|
||||
{
|
||||
@ -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)) ||
|
||||
|
Loading…
Reference in New Issue
Block a user