mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2025-04-12 06:54:41 -04:00
Merge 11f52a50a3
into d31ef12363
This commit is contained in:
commit
75a91a5e27
1 changed files with 54 additions and 2 deletions
|
@ -2178,12 +2178,40 @@ class PlayState extends MusicBeatSubState
|
|||
}
|
||||
}
|
||||
|
||||
var totalPressed:Int;
|
||||
/**
|
||||
* Callback executed when one of the note keys is pressed.
|
||||
*/
|
||||
function onKeyPress(event:PreciseInputEvent):Void
|
||||
{
|
||||
if (isGamePaused) return;
|
||||
if (isGamePaused)
|
||||
{
|
||||
var totalKeys:Int = 0;
|
||||
var totalPressed:Int = 0;
|
||||
var totalJustPressed:Int = 0;
|
||||
for (key in controls.getKeysForAction("note_" + event.noteDirection.toString()))
|
||||
{
|
||||
totalKeys++;
|
||||
if (FlxG.keys.anyPressed([key]))
|
||||
{
|
||||
totalPressed++;
|
||||
}
|
||||
if (FlxG.keys.anyJustPressed([key]))
|
||||
{
|
||||
totalJustPressed++;
|
||||
}
|
||||
}
|
||||
// A hack to ensure this all properly works despite the flixel moment
|
||||
if (playerStrumline.isKeyHeld(event.noteDirection) && totalPressed == 0) this.totalPressed = 3;
|
||||
else
|
||||
this.totalPressed = totalPressed;
|
||||
// trace('totalKeys ${totalKeys} totalPressed ${totalPressed} totalJustPressed ${totalJustPressed}');
|
||||
// If one or both of the note's keys is being held down, do nothing
|
||||
// Otherwise, the player has released and repressed the key, so pop the release input
|
||||
if ((totalPressed - totalJustPressed) <= 0) return;
|
||||
inputReleaseQueue.pop();
|
||||
return;
|
||||
}
|
||||
|
||||
// Do the minimal possible work here.
|
||||
inputPressQueue.push(event);
|
||||
|
@ -2194,8 +2222,32 @@ class PlayState extends MusicBeatSubState
|
|||
*/
|
||||
function onKeyRelease(event:PreciseInputEvent):Void
|
||||
{
|
||||
if (isGamePaused) return;
|
||||
if (isGamePaused)
|
||||
{
|
||||
var totalKeys:Int = 0;
|
||||
var totalJustReleased:Int = 0;
|
||||
|
||||
// If the key's still being pressed, don't add a release input
|
||||
for (key in controls.getKeysForAction("note_" + event.noteDirection.toString()))
|
||||
{
|
||||
totalKeys++;
|
||||
if (FlxG.keys.anyPressed([key]))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (FlxG.keys.anyJustPressed([key]))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (FlxG.keys.anyJustReleased([key]))
|
||||
{
|
||||
totalJustReleased++;
|
||||
}
|
||||
}
|
||||
// trace('release totalKeys ${totalKeys} totalPressed ${this.totalPressed} totalJustReleased ${totalJustReleased}');
|
||||
// Wait a second, a key's still being pressed, return!
|
||||
if (this.totalPressed >= 3 && totalJustReleased >= 3) return;
|
||||
}
|
||||
// Do the minimal possible work here.
|
||||
inputReleaseQueue.push(event);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue