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

Author Topic: Event::KeyPressed not working now?  (Read 2586 times)

0 Members and 1 Guest are viewing this topic.

expedo

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Event::KeyPressed not working now?
« on: June 04, 2019, 03:27:10 am »
Im doing this simple project where you can control and make the character jump, but whenever I do if (event.type == Event::KeyPressed) it wont execute the code in it when I press a key. Though this worked fine a while ago for some reason and my unfinished code is this:
(click to show/hide)

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Event::KeyPressed not working now?
« Reply #1 on: June 04, 2019, 06:39:39 am »
         if (event.type = Event::Closed)

This line is an assignment, not a comparison, and Event::Closed is (usually?) 0 so it'll not close the Window and it prevents handling any other event type because event.type is always Event::Closed.
Back to C++ gamedev with SFML in May 2023

expedo

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Event::KeyPressed not working now?
« Reply #2 on: June 04, 2019, 01:24:25 pm »
thanks