1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-24 15:56:30 +00:00
Funkin/source/GameOverState.hx

63 lines
1.5 KiB
Haxe
Raw Normal View History

2020-10-05 22:29:59 +00:00
package;
import flixel.FlxG;
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
{
override function create()
{
var loser:FlxSprite = new FlxSprite(100, 100);
var loseTex = FlxAtlasFrames.fromSparrow(AssetPaths.lose__png, AssetPaths.lose__xml);
loser.frames = loseTex;
loser.animation.addByPrefix('lose', 'lose', 24, false);
loser.animation.play('lose');
add(loser);
var restart:FlxSprite = new FlxSprite(500, 50).loadGraphic(AssetPaths.restart__png);
restart.setGraphicSize(Std.int(restart.width * 0.6));
restart.updateHitbox();
restart.alpha = 0;
restart.antialiasing = true;
add(restart);
FlxG.sound.music.fadeOut(2, FlxG.sound.music.volume * 0.6);
FlxTween.tween(restart, {alpha: 1}, 1, {ease: FlxEase.quartInOut});
FlxTween.tween(restart, {y: restart.y + 40}, 7, {ease: FlxEase.quartInOut, type: PINGPONG});
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;
}
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();
FlxG.switchState(new PlayState());
});
}
super.update(elapsed);
}
}