diff options
author | Nao Pross <naopross@thearcway.org> | 2018-02-12 20:33:48 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2018-02-12 20:33:48 +0100 |
commit | 92bec13dec53933a9cf8045ab486b47dc13fe46f (patch) | |
tree | de140535d5e6941bfd0f251e851f8a331ce6edf2 /src/main/cpp/Subconscious.cpp | |
parent | Fix pan (diff) | |
download | Subconscious-old-92bec13dec53933a9cf8045ab486b47dc13fe46f.tar.gz Subconscious-old-92bec13dec53933a9cf8045ab486b47dc13fe46f.zip |
Remove Actor::Type and Scene::Type in favor of dynamic_cast<T>()
Diffstat (limited to '')
-rw-r--r-- | src/main/cpp/Subconscious.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/main/cpp/Subconscious.cpp b/src/main/cpp/Subconscious.cpp index a5f8620..5d04e5c 100644 --- a/src/main/cpp/Subconscious.cpp +++ b/src/main/cpp/Subconscious.cpp @@ -34,26 +34,26 @@ void Subconscious::run() case sf::Event::KeyPressed: switch (event.key.code) { case sf::Keyboard::Up: - if (_currentScene->type == Scene::Type::WORLD) { - static_cast<WorldScene*>(_currentScene)->pan(0, -10); + if (WorldScene *worldScene = dynamic_cast<WorldScene*>(_currentScene)) { + worldScene->pan(0, -10); } break; case sf::Keyboard::Down: - if (_currentScene->type == Scene::Type::WORLD) { - static_cast<WorldScene*>(_currentScene)->pan(0, 10); + if (WorldScene *worldScene = dynamic_cast<WorldScene*>(_currentScene)) { + worldScene->pan(0, 10); } break; case sf::Keyboard::Left: - if (_currentScene->type == Scene::Type::WORLD) { - static_cast<WorldScene*>(_currentScene)->pan(-10, 0); + if (WorldScene *worldScene = dynamic_cast<WorldScene*>(_currentScene)) { + worldScene->pan(-10, 0); } break; case sf::Keyboard::Right: - if (_currentScene->type == Scene::Type::WORLD) { - static_cast<WorldScene*>(_currentScene)->pan(10, 0); + if (WorldScene *worldScene = dynamic_cast<WorldScene*>(_currentScene)) { + worldScene->pan(10, 0); } break; @@ -83,9 +83,8 @@ void Subconscious::run() // // std::cout << std::fixed << std::setprecision(3) // << event.mouseWheelScroll.delta << std::endl; - - if (_currentScene->type == Scene::Type::WORLD) { - static_cast<WorldScene*>(_currentScene)->zoom(event.mouseWheelScroll.delta/10.0); + if (WorldScene *worldScene = dynamic_cast<WorldScene*>(_currentScene)) { + worldScene->zoom(event.mouseWheelScroll.delta/10.0); } break; |