1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-15 19:33:36 +00:00
Funkin/source/funkin/ui/charSelect/CharSelectPlayer.hx

100 lines
2.7 KiB
Haxe
Raw Normal View History

2024-06-15 04:59:58 +00:00
package funkin.ui.charSelect;
import flixel.FlxSprite;
import funkin.graphics.adobeanimate.FlxAtlasSprite;
2024-08-28 00:48:56 +00:00
import flxanimate.animate.FlxKeyFrame;
2024-09-01 07:22:34 +00:00
import funkin.modding.IScriptedClass.IBPMSyncedScriptedClass;
import funkin.modding.events.ScriptEvent;
2024-06-15 04:59:58 +00:00
2024-09-01 07:22:34 +00:00
class CharSelectPlayer extends FlxAtlasSprite implements IBPMSyncedScriptedClass
2024-06-15 04:59:58 +00:00
{
2024-08-28 00:48:56 +00:00
var desLp:FlxKeyFrame = null;
2024-06-15 04:59:58 +00:00
public function new(x:Float, y:Float)
{
super(x, y, Paths.animateAtlas("charSelect/bfChill"));
2024-08-28 00:48:56 +00:00
desLp = anim.getFrameLabel("deselect loop start");
onAnimationComplete.add(function(animLabel:String) {
2024-08-28 00:48:56 +00:00
switch (animLabel)
{
case "slidein":
2024-09-01 07:22:34 +00:00
if (hasAnimation("slidein idle point"))
{
playAnimation("slidein idle point", true, false, false);
}
2024-08-28 00:48:56 +00:00
else
2024-09-01 07:22:34 +00:00
{
// Handled by onBeatHit now
playAnimation("idle", true, false, false);
}
2024-08-28 00:48:56 +00:00
case "slidein idle point":
2024-09-01 07:22:34 +00:00
// Handled by onBeatHit now
playAnimation("idle", true, false, false);
case "idle":
trace('Waiting for onBeatHit');
2024-08-28 00:48:56 +00:00
}
2024-06-15 04:59:58 +00:00
});
2024-08-22 21:36:43 +00:00
2024-08-28 00:48:56 +00:00
onAnimationFrame.add(function(animLabel:String, frame:Int) {
if (animLabel == "deselect" && desLp != null && frame >= desLp.index) playAnimation("deselect loop start", true, false, true);
});
2024-08-22 21:36:43 +00:00
}
2024-09-01 07:22:34 +00:00
public function onStepHit(event:SongTimeScriptEvent):Void {}
public function onBeatHit(event:SongTimeScriptEvent):Void
{
// TODO: There's a minor visual bug where there's a little stutter.
// This happens because the animation is getting restarted while it's already playing.
// I tried make this not interrupt an existing idle,
// but isAnimationFinished() and isLoopComplete() both don't work! What the hell?
// danceEvery isn't necessary if that gets fixed.
if (getCurrentAnimation() == "idle")
{
trace('Player beat hit');
playAnimation("idle", true, false, false);
}
};
2024-06-15 04:59:58 +00:00
public function updatePosition(str:String)
{
switch (str)
{
case "bf":
x = 0;
y = 0;
case "pico":
x = 0;
y = 0;
case "random":
}
}
public function switchChar(str:String)
{
switch str
{
default:
loadAtlas(Paths.animateAtlas("charSelect/" + str + "Chill"));
}
playAnimation("slidein", true, false, false);
2024-08-28 00:48:56 +00:00
desLp = anim.getFrameLabel("deselect loop start");
2024-06-15 04:59:58 +00:00
updateHitbox();
updatePosition(str);
}
2024-09-01 07:22:34 +00:00
public function onScriptEvent(event:ScriptEvent):Void {};
public function onCreate(event:ScriptEvent):Void {};
public function onDestroy(event:ScriptEvent):Void {};
public function onUpdate(event:UpdateScriptEvent):Void {};
2024-06-15 04:59:58 +00:00
}