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
I want to measure for how long the left mouse button is pressed - the command
this.input.activePointer.getDuration();
returns 0 UNTIL there is some other event on the input (like move) - then it indeed returns the time since
the left mouse button was pressed.
combination of
this.input.activePointer.downTime - this.time.now
works fine.
As far as I understand from the code in the /src/input/Pointer.js
getDuration: function ()
{
if (this.isDown)
{
return (this.time - this.downTime);
}
else
{
return (this.upTime - this.downTime);
}
},
the problem is that this.time returns Time when this Pointer was most recently updated by the Game step.
so if I press the left button and not move the mouse that time will be exactly the same as this.downTime
hence the duration reported will be 0.
(obviously on my laptop the Pointer is not considered updated by game step if it at least does not move so measuring duration of button press in this way does not work properly)
Example Test Code
if (this.input.activePointer.leftButtonDown()){
let time2 = this.time.now;
let time3 = this.input.activePointer.downTime;
let time = time2-time3;
time=this.input.activePointer.getDuration();
Additional Information
The text was updated successfully, but these errors were encountered:
Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.
Version
Firefox 65.0.2 (64 bit)
Description
I want to measure for how long the left mouse button is pressed - the command
this.input.activePointer.getDuration();
returns 0 UNTIL there is some other event on the input (like move) - then it indeed returns the time since
the left mouse button was pressed.
combination of
this.input.activePointer.downTime - this.time.now
works fine.
As far as I understand from the code in the /src/input/Pointer.js
getDuration: function ()
{
if (this.isDown)
{
return (this.time - this.downTime);
}
else
{
return (this.upTime - this.downTime);
}
},
the problem is that this.time returns Time when this Pointer was most recently updated by the Game step.
so if I press the left button and not move the mouse that time will be exactly the same as this.downTime
hence the duration reported will be 0.
(obviously on my laptop the Pointer is not considered updated by game step if it at least does not move so measuring duration of button press in this way does not work properly)
Example Test Code
if (this.input.activePointer.leftButtonDown()){
let time2 = this.time.now;
let time3 = this.input.activePointer.downTime;
let time = time2-time3;
time=this.input.activePointer.getDuration();
Additional Information
The text was updated successfully, but these errors were encountered: