You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Phaser Version:
v3.16.2-FB
Place the operating system below this comment.
Operating system:
Mac OS Sierra
Browser: (I tried with Firefox and Chrome, it happens in both of them)
Description
Key.duration isn't updated when the key is being held down. As a consequence, Keyboard.DownDuration and Keyboard.UpDuration don't work as intended either.
I can try to send a PR to fix this, but I'd need to know if Key.duration should be updated each frame, or I should make DownDuration and UpDuration work around that (in this case, probably Key.timeDown / Key.timeUp, which contain a timestamp)
The text was updated successfully, but these errors were encountered:
Thanks for this. Key.duration should only be changed when the key changes state (down to up), as Keys are not polled constantly while down. However, I've added a Key.getDuration method that will give you the value you need and updated the docs.
DownDuration was indeed broken and has been updated to use the game time, so you can call it at any stage now. UpDuration has been changed to do the same. These changes are all in the master branch now.
Version
v3.16.2-FB
Place the operating system below this comment.
Mac OS Sierra
Description
Key.duration
isn't updated when the key is being held down. As a consequence,Keyboard.DownDuration
andKeyboard.UpDuration
don't work as intended either.Looking at the source, it seems
duration
is only updated for resetting it to zero when the key has just been pressed down (https://github.com/photonstorm/phaser/blob/v3.16.2/src/input/keyboard/keys/Key.js#L269), but not when we keep holding it, and later on when the key is up.I'm not sure if this is the intended behavior for
Key.duration
, butDownDuration
andUpDuration
should work regardless.Example Test Code
Online snippet with full code at: https://codepen.io/ladybenko/pen/KYBRrw?editors=0010
Relevant part from above:
Additional Information
I can try to send a PR to fix this, but I'd need to know if
Key.duration
should be updated each frame, or I should makeDownDuration
andUpDuration
work around that (in this case, probablyKey.timeDown
/Key.timeUp
, which contain a timestamp)The text was updated successfully, but these errors were encountered: