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

FlxInput: Add Hold state/bool #3373

Open
Lasercar opened this issue Feb 20, 2025 · 4 comments
Open

FlxInput: Add Hold state/bool #3373

Lasercar opened this issue Feb 20, 2025 · 4 comments

Comments

@Lasercar
Copy link

Title. Why? Because Pressed and Just_Pressed return true at the same time it makes it impossible to only run or not run something if one of the keys of an action is already held down.

Modifying the behaviour of FlxInput to to make pressed only start returning after a frame might break some existing code, so add a new state called Hold that only returns true after the key's held for more than one frame?

I need this change in order to properly finish/fix this PR of mine:

FunkinCrew/Funkin#4145

@Geokureli
Copy link
Member

makes it impossible to only run or not run something if one of the keys of an action is already held down

Just use this?

if (FlxG.keys.pressed.SPACE && false == FlxG.keys.justPressed.SPACE)

@Lasercar
Copy link
Author

makes it impossible to only run or not run something if one of the keys of an action is already held down

Just use this?

if (FlxG.keys.pressed.SPACE && false == FlxG.keys.justPressed.SPACE)

Hmm, I'll try making a check for this with the controls - if one of the keys returns this, then return false.

@Geokureli
Copy link
Member

Geokureli commented Feb 20, 2025

if one of the keys returns this, then return false

the code I gave is a check to see if the space key was held, I imagine a check would use this to return true, not false.
example:

function isKeyHeld(key:FlxKey)
{
    return FlxG.keys.checkStatus(key, PRESSED) && false == FlxG.keys.checkStatus(key, JUST_PRESSED)
}

@Lasercar
Copy link
Author

Lasercar commented Feb 22, 2025

the code I gave is a check to see if the space key was held, I imagine a check would use this to return true, not false. example:

function isKeyHeld(key:FlxKey)
{
    return FlxG.keys.checkStatus(key, PRESSED) && false == FlxG.keys.checkStatus(key, JUST_PRESSED)
}

Yeah, that's my bad.

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