@@ -411,6 +411,24 @@ class CharSelectSubState extends MusicBeatSubState
411411 Conductor .stepHit .add (spamOnStep );
412412 // FlxG.debugger.track(temp, "tempBG");
413413
414+ #if FEATURE_TOUCH_CONTROLS
415+ addBackButton (FlxG .width , FlxG .height - 200 , FlxColor .WHITE , goBack , 0.3 , true );
416+
417+ if (backButton != null )
418+ {
419+ backButton .enabled = false ;
420+ backButton .cameras = [FlxG .camera ];
421+ }
422+
423+ FlxTween .tween (backButton , {x : FlxG .width - 230 }, 0.5 ,
424+ {
425+ ease : FlxEase .expoOut ,
426+ onComplete : (_ ) -> {
427+ if (backButton != null ) backButton .enabled = true ;
428+ }
429+ });
430+ #end
431+
414432 transitionGradient .loadGraphic (Paths .image (' freeplay/transitionGradient' ));
415433 transitionGradient .scale .set (1280 , 1 );
416434 transitionGradient .flipY = true ;
@@ -725,6 +743,13 @@ class CharSelectSubState extends MusicBeatSubState
725743 allowInput = false ;
726744 autoFollow = false ;
727745
746+ #if FEATURE_TOUCH_CONTROLS
747+ if (backButton != null )
748+ {
749+ FlxTween .tween (backButton , {alpha : 0 }, 0.2 );
750+ }
751+ #end
752+
728753 FlxTween .tween (cursor , {alpha : 0 }, 0.8 , {ease : FlxEase .expoOut });
729754 FlxTween .tween (cursorBlue , {alpha : 0 }, 0.8 , {ease : FlxEase .expoOut });
730755 FlxTween .tween (cursorDarkBlue , {alpha : 0 }, 0.8 , {ease : FlxEase .expoOut });
@@ -893,13 +918,7 @@ class CharSelectSubState extends MusicBeatSubState
893918 selectSound .play (true );
894919 }
895920
896- if (controls. BACK )
897- {
898- wentBackToFreeplay = true ;
899- FunkinSound .playOnce (Paths .sound (' cancelMenu' ));
900- FlxTween .tween (FlxG .sound .music , {volume : 0.0 }, 0.7 , {ease : FlxEase .quadInOut });
901- goToFreeplay ();
902- }
921+ if (controls. BACK ) goBack ();
903922 }
904923
905924 if (cursorX < - 1 )
@@ -933,6 +952,13 @@ class CharSelectSubState extends MusicBeatSubState
933952
934953 dispatchEvent (new CharacterSelectScriptEvent (CHARACTER_DESELECTED , curChar ));
935954
955+ #if FEATURE_TOUCH_CONTROLS
956+ if (backButton != null )
957+ {
958+ backButton .enabled = true ;
959+ }
960+ #end
961+
936962 FlxTween .globalManager .cancelTweensOf (FlxG .sound .music );
937963 FlxTween .tween (FlxG .sound .music , {pitch : 1.0 , volume : 1.0 }, 1 , {ease : FlxEase .quartInOut });
938964 playerChill .playAnimation (" deselect" );
@@ -969,19 +995,19 @@ class CharSelectSubState extends MusicBeatSubState
969995
970996 dispatchEvent (new CharacterSelectScriptEvent (CHARACTER_CONFIRMED , curChar ));
971997
998+ #if FEATURE_TOUCH_CONTROLS
999+ if (backButton != null )
1000+ {
1001+ backButton .enabled = false ;
1002+ }
1003+ #end
1004+
9721005 FlxTween .tween (FlxG .sound .music , {pitch : 0.1 }, 1 , {ease : FlxEase .quadInOut });
9731006 FlxTween .tween (FlxG .sound .music , {volume : 0.0 }, 1.5 , {ease : FlxEase .quadInOut });
9741007 playerChill .playAnimation (" select" );
9751008 gfChill .playAnimation (" confirm" , true , false , true );
9761009 pressedSelect = true ;
9771010 selectTimer .start (1.5 , (_ ) -> {
978- // pressedSelect = false;
979- // FlxG.switchState(FreeplayState.build(
980- // {
981- // {
982- // character: curChar
983- // }
984- // }));
9851011 goToFreeplay ();
9861012 });
9871013 }
@@ -1045,6 +1071,23 @@ class CharSelectSubState extends MusicBeatSubState
10451071 cursorDenied .y = cursor .y - 4 ;
10461072 }
10471073
1074+ function goBack (): Void
1075+ {
1076+ #if FEATURE_TOUCH_CONTROLS
1077+ if (backButton != null )
1078+ {
1079+ backButton .enabled = false ;
1080+ backButton .alpha = 1 ;
1081+ backButton .animation .play (" confirm" );
1082+ }
1083+ #end
1084+
1085+ wentBackToFreeplay = true ;
1086+ FunkinSound .playOnce (Paths .sound (' cancelMenu' ));
1087+ FlxTween .tween (FlxG .sound .music , {volume : 0.0 }, 0.7 , {ease : FlxEase .quadInOut });
1088+ goToFreeplay ();
1089+ }
1090+
10481091 var bopTimer : Float = 0 ;
10491092 var delay = 1 / 24 ;
10501093 var bopFr = 0 ;
0 commit comments