2023-11-07 04:04:22 -05:00
|
|
|
package funkin.ui;
|
2020-10-30 17:18:26 -04:00
|
|
|
|
|
|
|
import flixel.FlxSprite;
|
|
|
|
import flixel.graphics.frames.FlxAtlasFrames;
|
|
|
|
import flixel.group.FlxSpriteGroup;
|
2020-10-30 17:55:20 -04:00
|
|
|
import flixel.math.FlxMath;
|
2023-11-07 04:04:22 -05:00
|
|
|
import funkin.util.MathUtil;
|
2021-03-01 22:35:27 -05:00
|
|
|
import flixel.util.FlxColor;
|
2020-10-30 17:18:26 -04:00
|
|
|
|
|
|
|
class MenuItem extends FlxSpriteGroup
|
|
|
|
{
|
2023-01-22 22:25:45 -05:00
|
|
|
public var targetY:Float = 0;
|
|
|
|
public var week:FlxSprite;
|
|
|
|
|
|
|
|
public function new(x:Float, y:Float, weekNum:Int = 0, weekType:WeekType)
|
|
|
|
{
|
|
|
|
super(x, y);
|
|
|
|
|
|
|
|
var weekStr:String = switch (weekType)
|
|
|
|
{
|
|
|
|
case WEEK:
|
|
|
|
"week";
|
|
|
|
case WEEKEND:
|
|
|
|
"weekend";
|
|
|
|
}
|
|
|
|
|
|
|
|
week = new FlxSprite().loadGraphic(Paths.image('storymenu/' + weekStr + weekNum));
|
|
|
|
add(week);
|
|
|
|
}
|
|
|
|
|
|
|
|
var isFlashing:Bool = false;
|
2024-05-13 14:23:16 -04:00
|
|
|
var flashTick:Float = 0;
|
|
|
|
final flashFramerate:Float = 20;
|
2023-01-22 22:25:45 -05:00
|
|
|
|
|
|
|
public function startFlashing():Void
|
|
|
|
{
|
|
|
|
isFlashing = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
|
|
|
super.update(elapsed);
|
2023-11-07 04:04:22 -05:00
|
|
|
y = MathUtil.coolLerp(y, (targetY * 120) + 480, 0.17);
|
2023-01-22 22:25:45 -05:00
|
|
|
|
2024-05-13 14:23:16 -04:00
|
|
|
if (isFlashing)
|
|
|
|
{
|
|
|
|
flashTick += elapsed;
|
|
|
|
if (flashTick >= 1 / flashFramerate)
|
|
|
|
{
|
|
|
|
flashTick %= 1 / flashFramerate;
|
|
|
|
week.color = (week.color == FlxColor.WHITE) ? 0xFF33ffff : FlxColor.WHITE;
|
|
|
|
}
|
|
|
|
}
|
2023-01-22 22:25:45 -05:00
|
|
|
}
|
2020-10-30 17:18:26 -04:00
|
|
|
}
|
2022-08-25 01:35:47 -04:00
|
|
|
|
|
|
|
enum abstract WeekType(String) to String
|
|
|
|
{
|
2023-01-22 22:25:45 -05:00
|
|
|
var WEEK;
|
|
|
|
var WEEKEND;
|
2022-08-25 01:35:47 -04:00
|
|
|
}
|