Skip to content

Commit 7de11f4

Browse files
committed
Snap charSelect cursor's positions on create and move them in an in/out motion sequence
1 parent 8952aca commit 7de11f4

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

source/funkin/ui/charSelect/CharSelectCursors.hx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class CharSelectCursors extends FlxTypedSpriteContainer<FunkinSprite>
1818
var cursorConfirmed:FunkinSprite;
1919
var cursorDenied:FunkinSprite;
2020

21+
var cursorsIntroOutroOffset:Float = 240;
22+
2123
public function new()
2224
{
2325
super();
@@ -103,4 +105,38 @@ class CharSelectCursors extends FlxTypedSpriteContainer<FunkinSprite>
103105
cursorDenied.x = main.x - 2;
104106
cursorDenied.y = main.y - 4;
105107
}
108+
109+
public function snapToLocation(intendedPosition:FlxPoint):Void
110+
{
111+
main.setPosition(intendedPosition.x, intendedPosition.y);
112+
lightBlue.setPosition(intendedPosition.x, intendedPosition.y); // Using intendedPosition since we anyway snapping them
113+
darkBlue.setPosition(intendedPosition.x, intendedPosition.y);
114+
cursorConfirmed.setPosition(main.x - 2, main.x - 4);
115+
cursorDenied.setPosition(main.x - 2, main.x - 4);
116+
}
117+
118+
public function slide(slideIn:Bool)
119+
{
120+
if (slideIn)
121+
{
122+
main.alpha = 0;
123+
lightBlue.alpha = 0;
124+
darkBlue.alpha = 0;
125+
126+
main.y += cursorsIntroOutroOffset;
127+
lightBlue.y += cursorsIntroOutroOffset;
128+
darkBlue.y += cursorsIntroOutroOffset;
129+
130+
FlxTween.tween(main, {alpha: 1, y: main.y - cursorsIntroOutroOffset}, 0.9, {ease: FlxEase.expoOut});
131+
FlxTween.tween(lightBlue, {alpha: 1, y: lightBlue.y - cursorsIntroOutroOffset}, 0.95, {ease: FlxEase.expoOut});
132+
FlxTween.tween(darkBlue, {alpha: 1, y: darkBlue.y - cursorsIntroOutroOffset}, 1.0, {ease: FlxEase.expoOut});
133+
}
134+
else
135+
{
136+
FlxTween.tween(main, {alpha: 0, y: main.y + cursorsIntroOutroOffset}, 0.8, {ease: FlxEase.backIn});
137+
FlxTween.tween(lightBlue, {alpha: 0, y: lightBlue.y + cursorsIntroOutroOffset}, 0.82, {ease: FlxEase.backIn});
138+
FlxTween.tween(darkBlue, {alpha: 0, y: darkBlue.y + cursorsIntroOutroOffset}, 0.84, {ease: FlxEase.backIn});
139+
FlxTween.tween(cursorConfirmed, {alpha: 0, y: cursorConfirmed.y + cursorsIntroOutroOffset}, 0.8, {ease: FlxEase.expoOut});
140+
}
141+
}
106142
}

source/funkin/ui/charSelect/CharSelectSubState.hx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,15 @@ class CharSelectSubState extends MusicBeatSubState
357357
FlxTween.tween(member, {y: member.y - 300}, 1, {ease: FlxEase.expoOut});
358358
}
359359

360+
cursorLocIntended.x = (cursorFactor * cursorX) + (FlxG.width / 2) - cursors.main.width / 2;
361+
cursorLocIntended.y = (cursorFactor * cursorY) + (FlxG.height / 2) - cursors.main.height / 2;
362+
363+
cursorLocIntended.x += cursorOffsetX;
364+
cursorLocIntended.y += cursorOffsetY;
365+
366+
cursors.snapToLocation(cursorLocIntended);
367+
cursors.slide(true);
368+
360369
FlxG.debugger.addTrackerProfile(new TrackerProfile(CharSelectSubState, ["curChar", "grpXSpread", "grpYSpread"]));
361370
FlxG.debugger.track(this);
362371

@@ -683,7 +692,7 @@ class CharSelectSubState extends MusicBeatSubState
683692
}
684693
#end
685694

686-
FlxTween.tween(cursors, {alpha: 0}, 0.8, {ease: FlxEase.expoOut});
695+
cursors.slide(false);
687696

688697
FlxTween.tween(barthing, {y: barthing.y + 80}, 0.8, {ease: FlxEase.backIn});
689698
FlxTween.tween(nametag, {y: nametag.y + 80}, 0.8, {ease: FlxEase.backIn});

0 commit comments

Comments
 (0)