mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 06:28:30 +00:00
Updated to use game clock time values.
This commit is contained in:
parent
6b5383a007
commit
181be88ba9
2 changed files with 12 additions and 8 deletions
|
@ -5,8 +5,8 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Returns `true` if the Key was pressed down within the `duration` value given, or `false` if it either isn't down,
|
||||
* or was pressed down longer ago than then given duration.
|
||||
* Returns `true` if the Key was pressed down within the `duration` value given, based on the current
|
||||
* game clock time. Or `false` if it either isn't down, or was pressed down longer ago than the given duration.
|
||||
*
|
||||
* @function Phaser.Input.Keyboard.DownDuration
|
||||
* @since 3.0.0
|
||||
|
@ -14,13 +14,15 @@
|
|||
* @param {Phaser.Input.Keyboard.Key} key - The Key object to test.
|
||||
* @param {integer} [duration=50] - The duration, in ms, within which the key must have been pressed down.
|
||||
*
|
||||
* @return {boolean} `true` if the Key was pressed down within `duration` ms, otherwise `false`.
|
||||
* @return {boolean} `true` if the Key was pressed down within `duration` ms ago, otherwise `false`.
|
||||
*/
|
||||
var DownDuration = function (key, duration)
|
||||
{
|
||||
if (duration === undefined) { duration = 50; }
|
||||
|
||||
return (key.isDown && key.duration < duration);
|
||||
var current = key.plugin.game.loop.time - key.timeDown;
|
||||
|
||||
return (key.isDown && current < duration);
|
||||
};
|
||||
|
||||
module.exports = DownDuration;
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Returns `true` if the Key was released within the `duration` value given, or `false` if it either isn't up,
|
||||
* or was released longer ago than then given duration.
|
||||
* Returns `true` if the Key was released within the `duration` value given, based on the current
|
||||
* game clock time. Or returns `false` if it either isn't up, or was released longer ago than the given duration.
|
||||
*
|
||||
* @function Phaser.Input.Keyboard.UpDuration
|
||||
* @since 3.0.0
|
||||
|
@ -14,13 +14,15 @@
|
|||
* @param {Phaser.Input.Keyboard.Key} key - The Key object to test.
|
||||
* @param {integer} [duration=50] - The duration, in ms, within which the key must have been released.
|
||||
*
|
||||
* @return {boolean} `true` if the Key was released within `duration` ms, otherwise `false`.
|
||||
* @return {boolean} `true` if the Key was released within `duration` ms ago, otherwise `false`.
|
||||
*/
|
||||
var UpDuration = function (key, duration)
|
||||
{
|
||||
if (duration === undefined) { duration = 50; }
|
||||
|
||||
return (key.isUp && key.duration < duration);
|
||||
var current = key.plugin.game.loop.time - key.timeUp;
|
||||
|
||||
return (key.isUp && current < duration);
|
||||
};
|
||||
|
||||
module.exports = UpDuration;
|
||||
|
|
Loading…
Add table
Reference in a new issue