Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key.duration initial value not 0 in v2.0.5 #932

Closed
DrHackenstein opened this issue Jun 22, 2014 · 2 comments
Closed

Key.duration initial value not 0 in v2.0.5 #932

DrHackenstein opened this issue Jun 22, 2014 · 2 comments

Comments

@DrHackenstein
Copy link

Key.duration should be "the number of milliseconds this key has been held down for." with default value 0. However I've found that the inital value before the key has been pushed is in fact something else >0. Not sure how that happens, but it's easy to test by printing out the value:

var key = this.keyboard.addKey(Phaser.Keyboard.SPACEBAR);
update()
{
console.log("Duration: " + key.duration);
}

@DrHackenstein
Copy link
Author

Could be due to Key.reset line 205 in the docs: http://docs.phaser.io/Key.js.html#sunlight-1-line-191
this.duration = this.game.time.now - this.timeDown;
this.timeDown is initially 0, so if reset is called before the key was down at all duration would just become the time at that point. Looking at the values that seems reasonable.

@photonstorm
Copy link
Collaborator

I can't see any reason to not just set duration to zero in Key.reset, so have done so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants