2020-10-30 17:18:26 -04:00
|
|
|
package;
|
|
|
|
|
2021-03-01 22:35:27 -05:00
|
|
|
import flixel.FlxG;
|
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;
|
2021-03-01 22:35:27 -05:00
|
|
|
import flixel.util.FlxColor;
|
2020-10-30 17:18:26 -04:00
|
|
|
|
|
|
|
class MenuItem extends FlxSpriteGroup
|
|
|
|
{
|
2020-10-30 17:55:20 -04:00
|
|
|
public var targetY:Float = 0;
|
2020-10-30 21:55:09 -04:00
|
|
|
public var week:FlxSprite;
|
2021-03-01 22:35:27 -05:00
|
|
|
public var flashingInt:Int = 0;
|
2020-10-30 17:55:20 -04:00
|
|
|
|
2020-11-06 05:21:29 -05:00
|
|
|
public function new(x:Float, y:Float, weekNum:Int = 0)
|
2020-10-30 17:18:26 -04:00
|
|
|
{
|
|
|
|
super(x, y);
|
2021-03-01 22:35:27 -05:00
|
|
|
week = new FlxSprite().loadGraphic(Paths.image('storymenu/week' + weekNum));
|
2020-10-30 17:18:26 -04:00
|
|
|
add(week);
|
2021-03-01 22:35:27 -05:00
|
|
|
}
|
2020-10-30 17:18:26 -04:00
|
|
|
|
2021-03-01 22:35:27 -05:00
|
|
|
private var isFlashing:Bool = false;
|
|
|
|
|
|
|
|
public function startFlashing():Void
|
|
|
|
{
|
|
|
|
isFlashing = true;
|
2020-10-30 17:18:26 -04:00
|
|
|
}
|
2020-10-30 17:55:20 -04:00
|
|
|
|
2021-03-01 22:35:27 -05:00
|
|
|
// if it runs at 60fps, fake framerate will be 6
|
|
|
|
// if it runs at 144 fps, fake framerate will be like 14, and will update the graphic every 0.016666 * 3 seconds still???
|
|
|
|
// so it runs basically every so many seconds, not dependant on framerate??
|
|
|
|
// I'm still learning how math works thanks whoever is reading this lol
|
|
|
|
var fakeFramerate:Int = Math.round((1 / FlxG.elapsed) / 10);
|
|
|
|
|
2020-10-30 17:55:20 -04:00
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
|
|
|
super.update(elapsed);
|
2021-04-13 22:02:21 -04:00
|
|
|
y = CoolUtil.coolLerp(y, (targetY * 120) + 480, 0.17);
|
2021-03-01 22:35:27 -05:00
|
|
|
|
|
|
|
if (isFlashing)
|
|
|
|
flashingInt += 1;
|
|
|
|
|
|
|
|
if (flashingInt % fakeFramerate >= Math.floor(fakeFramerate / 2))
|
|
|
|
week.color = 0xFF33ffff;
|
|
|
|
else
|
|
|
|
week.color = FlxColor.WHITE;
|
2020-10-30 17:55:20 -04:00
|
|
|
}
|
2020-10-30 17:18:26 -04:00
|
|
|
}
|