[ad_1]
sf::Event::KeyPressed & sf::Event::KeyReleased are occasions triggerd when that factor is completed. Where as isKeyPressed is a operate that tells you if a key’s pressed proper now in that iteration of the window loop.
In common Events are used to do single issues at a time. Everything else is usedd in every iteration. Any occasion set off triggers a single occasion even when that occasion is ongoing all through many iterations of the sport loop.
A very good instance of utilization of those two is character motion onscreen.
Moving a personality with an occasion occasion::Keypressed(Left) will act like a keyPress throughout writing textual content. Try holding down any letter in your keyboard in like a notepad. You’ll see your single letter pop up as soon as after which after delay a number of letters observe slowly.
With isKeypressed you might have a sudden set off thats continous till unfulfilled. For character motion isKeyPressed is the one to make use of.
For instance button utilization onscreen could be higher accomplished in occasions as you may maintain that button down and solely need a single click on on it. occasion::Keypressed could be higher then.
Also i like to recommend including the occasion::Keypressed with one other assertion saying which key was pressed:
occasion.kind == sf::occasion::keyPressed && sf::keyboard::is::keypressed(LeftP)
The above is used contained in the occasion loop
you shouldnt use occasions outdoors the occasion loop. it might be pointless
[ad_2]