Hi there. I successfully compiled and linked Thor 2.0 into my current project, and I'm using actions to rework some of my buttons, key commands, etc. However, whenever you click once on mouse or whatever, it does the action atleast 5 times, and it's getting extremely annoying. Here's some example code:
I initialize the actions:
thor::Action m_exitAction;
thor::Action m_mouseClickedAction;
thor::Action m_fpsShortcut;
Init them with the constructor:
m_exitAction(sf::Event::Closed),
m_mouseClickedAction(sf::Mouse::Left),
m_fpsShortcut(sf::Keyboard::F)
I've also tried thor::Action::PressOnce, and that makes the key or mouse button click infinitely.
And set them to the corresponding enumators:
m_actions[EXITACTION] = m_exitAction;
m_actions[LMOUSECLICKACTION] = m_mouseClickedAction
m_actions[FPSSHORTCUTACTION] = m_fpsShortcut;
Then I actually use it:
void CIntroState::update() {
while(m_game.screen.pollEvent(event))
m_game.getActionMap().pushEvent(event);
if (m_game.getActionMap().isActive(CGameEngine::Actions::EXITACTION))
m_game.quit();
else if (m_game.getActionMap().isActive(CGameEngine::Actions::LMOUSECLICKACTION))
{
if (m_play.isHoveredOver(m_game.screen))
m_next = m_game.build<CIntroState>(true);
else if (m_options.isHoveredOver(m_game.screen))
m_next = m_game.build<CSettingsState>(true);
else if (m_exit.isHoveredOver(m_game.screen))
m_game.quit();
}
else if (m_game.getActionMap().isActive(CGameEngine::Actions::FPSSHORTCUTACTION))
{
if (m_game.getFPSOn())
m_game.setFPSOn(false);
else
m_game.setFPSOn(true);
m_game.saveOptions();
std::cout << "FPS has the value: " << m_game.getFPSOn() << " now." << std::endl;
}
}
I appreciate any answers.