LoadingState.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "LoadingState.hpp"
  2. #include "../AssetManager.hpp"
  3. #include <TweenEngine/Tween.h>
  4. #include <cpp3ds/Window/Window.hpp>
  5. #include <cpp3ds/System/I18n.hpp>
  6. #include <cpp3ds/System/Service.hpp>
  7. namespace FreeShop {
  8. LoadingState::LoadingState(StateStack& stack, Context& context, StateCallback callback)
  9. : State(stack, context, callback)
  10. {
  11. m_background.setSize(cpp3ds::Vector2f(400.f, 240.f));
  12. m_background.setFillColor(cpp3ds::Color(0, 0, 0, 50));
  13. m_icon.setFont(AssetManager<cpp3ds::Font>::get("fonts/fontawesome.ttf"));
  14. m_icon.setFillColor(cpp3ds::Color(110,110,110,255));
  15. m_icon.setCharacterSize(80);
  16. m_icon.setString(L"\uf110");
  17. cpp3ds::FloatRect textRect = m_icon.getLocalBounds();
  18. m_icon.setOrigin(textRect.left + textRect.width / 2.f, textRect.top + 1.f + textRect.height / 2.f);
  19. m_icon.setPosition(160.f, 120.f);
  20. m_icon.setScale(0.5f, 0.5f);
  21. }
  22. void LoadingState::renderTopScreen(cpp3ds::Window& window)
  23. {
  24. //
  25. }
  26. void LoadingState::renderBottomScreen(cpp3ds::Window& window)
  27. {
  28. // window.draw(m_background);
  29. window.draw(m_icon);
  30. }
  31. bool LoadingState::update(float delta)
  32. {
  33. if (m_rotateClock.getElapsedTime() > cpp3ds::milliseconds(80))
  34. {
  35. m_icon.rotate(45);
  36. m_rotateClock.restart();
  37. }
  38. return true;
  39. }
  40. bool LoadingState::processEvent(const cpp3ds::Event& event)
  41. {
  42. return false;
  43. }
  44. } // namespace FreeShop