1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-14 02:42:55 +00:00
Funkin/source/GameOverState.hx

82 lines
1.9 KiB
Haxe
Raw Normal View History

2020-10-05 22:29:59 +00:00
package;
import flixel.FlxSprite;
import flixel.addons.transition.FlxTransitionableState;
import flixel.graphics.frames.FlxAtlasFrames;
2020-10-09 07:29:00 +00:00
import flixel.input.gamepad.FlxGamepad;
2020-10-05 22:29:59 +00:00
import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween;
class GameOverState extends FlxTransitionableState
{
2020-10-27 10:35:23 +00:00
var bfX:Float = 0;
var bfY:Float = 0;
public function new(x:Float, y:Float)
{
super();
bfX = x;
bfY = y;
}
2020-10-05 22:29:59 +00:00
override function create()
{
2020-10-27 10:35:23 +00:00
/* var loser:FlxSprite = new FlxSprite(100, 100);
2021-01-04 23:56:30 +00:00
var loseTex = FlxAtlasFrames.fromSparrow(AssetPaths.lose.png, AssetPaths.lose.xml);
2020-10-27 10:35:23 +00:00
loser.frames = loseTex;
loser.animation.addByPrefix('lose', 'lose', 24, false);
loser.animation.play('lose');
// add(loser); */
var bf:Boyfriend = new Boyfriend(bfX, bfY);
// bf.scrollFactor.set();
add(bf);
bf.playAnim('firstDeath');
FlxG.camera.follow(bf, LOCKON, 0.001);
/*
2021-01-04 23:56:30 +00:00
var restart:FlxSprite = new FlxSprite(500, 50).loadGraphic(AssetPaths.restart.png);
2020-10-27 10:35:23 +00:00
restart.setGraphicSize(Std.int(restart.width * 0.6));
restart.updateHitbox();
restart.alpha = 0;
restart.antialiasing = true;
// add(restart); */
2020-10-05 22:29:59 +00:00
FlxG.sound.music.fadeOut(2, FlxG.sound.music.volume * 0.6);
2020-10-27 10:35:23 +00:00
// FlxTween.tween(restart, {alpha: 1}, 1, {ease: FlxEase.quartInOut});
// FlxTween.tween(restart, {y: restart.y + 40}, 7, {ease: FlxEase.quartInOut, type: PINGPONG});
2020-10-05 22:29:59 +00:00
super.create();
}
private var fading:Bool = false;
override function update(elapsed:Float)
{
2020-10-09 07:29:00 +00:00
var pressed:Bool = FlxG.keys.justPressed.ANY;
var gamepad:FlxGamepad = FlxG.gamepads.lastActive;
if (gamepad != null)
{
if (gamepad.justPressed.ANY)
pressed = true;
}
2020-10-27 10:35:23 +00:00
pressed = false;
2020-10-09 07:29:00 +00:00
if (pressed && !fading)
2020-10-05 22:29:59 +00:00
{
fading = true;
FlxG.sound.music.fadeOut(0.5, 0, function(twn:FlxTween)
{
FlxG.sound.music.stop();
LoadingState.loadAndSwitchState(new PlayState());
2020-10-05 22:29:59 +00:00
});
}
super.update(elapsed);
}
}