Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Query about handling input across many classes  (Read 1146 times)

0 Members and 1 Guest are viewing this topic.

smilesprower

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • Email
Query about handling input across many classes
« on: January 26, 2017, 01:57:33 am »
Just wondering what is the correct way to handle input across many classes. Example title scene, game scene.
Should each scene have sf::event or is there a preferred way for going about this.

Thanks

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Query about handling input across many classes
« Reply #1 on: January 26, 2017, 02:09:51 am »
Depends a bit how you manage your different scenes.

Generally you want to have one event loop, where you poll all the events. From there you can pass the event on to different places.

For example if you use some sort of message bus, you could then hand of all the events to that and the bus will take care of pushing it to the right subscribers.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything