From 9775034d7aaa8cdabd5c128d3c7a3ebedcaebb65 Mon Sep 17 00:00:00 2001 From: zacksgamerz <81515012+zacksgamerz@users.noreply.github.com> Date: Sun, 12 Jan 2025 17:22:37 +0700 Subject: [PATCH] Add tapping to LetterSort for Freeplay. --- source/funkin/ui/freeplay/FreeplayState.hx | 1 - source/funkin/ui/freeplay/LetterSort.hx | 48 +++++++++++++++++++--- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/source/funkin/ui/freeplay/FreeplayState.hx b/source/funkin/ui/freeplay/FreeplayState.hx index f0de30287..9f15b3c1f 100644 --- a/source/funkin/ui/freeplay/FreeplayState.hx +++ b/source/funkin/ui/freeplay/FreeplayState.hx @@ -584,7 +584,6 @@ class FreeplayState extends MusicBeatSubState } else if (grpCapsules.members.length > 0) { - FunkinSound.playOnce(Paths.sound('scrollMenu'), 0.4); curSelected = 1; changeSelection(); } diff --git a/source/funkin/ui/freeplay/LetterSort.hx b/source/funkin/ui/freeplay/LetterSort.hx index 8200cecc8..d4db8c915 100644 --- a/source/funkin/ui/freeplay/LetterSort.hx +++ b/source/funkin/ui/freeplay/LetterSort.hx @@ -13,10 +13,12 @@ import funkin.input.Controls; import funkin.util.SwipeUtil; import funkin.util.TouchUtil; import funkin.graphics.adobeanimate.FlxAtlasSprite; +import funkin.audio.FunkinSound; class LetterSort extends FlxSpriteGroup { public var letters:Array = []; + public var letterHitboxes:Array = []; // starts at 2, cuz that's the middle letter on start (accounting for fav and #, it should begin at ALL filter) var curSelection:Int = 2; @@ -50,6 +52,11 @@ class LetterSort extends FlxSpriteGroup // letter.visible = false; add(letter); + var letterHitbox:FlxObject = new FlxObject(letter.x - 50, letter.y - 50, 50, 50); + letterHitbox.cameras = cameras; + letterHitbox.active = false; + letterHitboxes.push(letterHitbox); + letters.push(letter); if (i != 2) letter.scale.x = letter.scale.y = 0.8; @@ -69,11 +76,16 @@ class LetterSort extends FlxSpriteGroup grpSeperators.push(sep); } + var letterHitbox:FlxObject = new FlxObject(0, 0, 1, 1); + letterHitbox.cameras = cameras; + letterHitbox.active = false; + letterHitboxes.push(letterHitbox); + rightArrow = new FlxSprite(380, 15).loadGraphic(Paths.image("freeplay/miniArrow")); // rightArrow.animation.play("arrow"); add(rightArrow); - swipeBounds = new FlxObject(400, 60, 420, 80); + swipeBounds = new FlxObject(440, 60, 460, 80); swipeBounds.cameras = cameras; swipeBounds.active = false; @@ -94,14 +106,37 @@ class LetterSort extends FlxSpriteGroup if (inputEnabled) { - if (controls.FREEPLAY_LEFT - || (instance != null && TouchUtil.overlaps(swipeBounds, instance.funnyCam) && SwipeUtil.swipeLeft)) changeSelection(-1); - if (controls.FREEPLAY_RIGHT - || (instance != null && TouchUtil.overlaps(swipeBounds, instance.funnyCam) && SwipeUtil.swipeRight)) changeSelection(1); + if (TouchUtil.justReleased && TouchUtil.touch.ticksDeltaSincePress < 200) + { + for (index => letter in letterHitboxes) + { + if (!TouchUtil.overlaps(letter, instance.funnyCam)) continue; + if (index == 2 || index == 5) continue; + + var selectionChanges:Array = [-1, -1, 0, 1, 1]; + var changeValue = selectionChanges[index]; + + if (changeValue != 0) + { + changeSelection(changeValue); + + if (index == 0 || index == 4) + { + changeSelection(changeValue, false); + } + } + + break; + } + } + + if (controls.FREEPLAY_LEFT || (TouchUtil.overlaps(swipeBounds, instance.funnyCam) && SwipeUtil.swipeLeft)) changeSelection(-1); + + if (controls.FREEPLAY_RIGHT || (TouchUtil.overlaps(swipeBounds, instance.funnyCam) && SwipeUtil.swipeRight)) changeSelection(1); } } - public function changeSelection(diff:Int = 0):Void + public function changeSelection(diff:Int = 0, playSound:Bool = true):Void { doLetterChangeAnims(diff); @@ -114,6 +149,7 @@ class LetterSort extends FlxSpriteGroup new FlxTimer().start(2 / 24, function(_) { arrowToMove.offset.x = 0; }); + if (playSound) FunkinSound.playOnce(Paths.sound('scrollMenu'), 0.4); } /**