mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-12-11 08:41:25 -05:00
flash fix
This commit is contained in:
parent
34a6e16385
commit
c49b66f0e4
2 changed files with 23 additions and 24 deletions
|
@ -11,7 +11,6 @@ class MenuItem extends FlxSpriteGroup
|
||||||
{
|
{
|
||||||
public var targetY:Float = 0;
|
public var targetY:Float = 0;
|
||||||
public var week:FlxSprite;
|
public var week:FlxSprite;
|
||||||
public var flashingInt:Int = 0;
|
|
||||||
|
|
||||||
public function new(x:Float, y:Float, weekNum:Int = 0, weekType:WeekType)
|
public function new(x:Float, y:Float, weekNum:Int = 0, weekType:WeekType)
|
||||||
{
|
{
|
||||||
|
@ -30,28 +29,28 @@ class MenuItem extends FlxSpriteGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
var isFlashing:Bool = false;
|
var isFlashing:Bool = false;
|
||||||
|
var flashTick:Float = 0;
|
||||||
|
final flashFramerate:Float = 20;
|
||||||
|
|
||||||
public function startFlashing():Void
|
public function startFlashing():Void
|
||||||
{
|
{
|
||||||
isFlashing = true;
|
isFlashing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
override function update(elapsed:Float)
|
override function update(elapsed:Float)
|
||||||
{
|
{
|
||||||
super.update(elapsed);
|
super.update(elapsed);
|
||||||
y = MathUtil.coolLerp(y, (targetY * 120) + 480, 0.17);
|
y = MathUtil.coolLerp(y, (targetY * 120) + 480, 0.17);
|
||||||
|
|
||||||
if (isFlashing) flashingInt += 1;
|
if (isFlashing)
|
||||||
|
{
|
||||||
if (flashingInt % fakeFramerate >= Math.floor(fakeFramerate / 2)) week.color = 0xFF33ffff;
|
flashTick += elapsed;
|
||||||
else
|
if (flashTick >= 1 / flashFramerate)
|
||||||
week.color = FlxColor.WHITE;
|
{
|
||||||
|
flashTick %= 1 / flashFramerate;
|
||||||
|
week.color = (week.color == FlxColor.WHITE) ? 0xFF33ffff : FlxColor.WHITE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,13 +13,10 @@ class LevelTitle extends FlxSpriteGroup
|
||||||
public final level:Level;
|
public final level:Level;
|
||||||
|
|
||||||
public var targetY:Float;
|
public var targetY:Float;
|
||||||
public var isFlashing:Bool = false;
|
|
||||||
|
|
||||||
var title:FlxSprite;
|
var title:FlxSprite;
|
||||||
var lock:FlxSprite;
|
var lock:FlxSprite;
|
||||||
|
|
||||||
var flashingInt:Int = 0;
|
|
||||||
|
|
||||||
public function new(x:Int, y:Int, level:Level)
|
public function new(x:Int, y:Int, level:Level)
|
||||||
{
|
{
|
||||||
super(x, y);
|
super(x, y);
|
||||||
|
@ -46,20 +43,23 @@ class LevelTitle extends FlxSpriteGroup
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if it runs at 60fps, fake framerate will be 6
|
public var isFlashing:Bool = false;
|
||||||
// if it runs at 144 fps, fake framerate will be like 14, and will update the graphic every 0.016666 * 3 seconds still???
|
var flashTick:Float = 0;
|
||||||
// so it runs basically every so many seconds, not dependant on framerate??
|
final flashFramerate:Float = 20;
|
||||||
// I'm still learning how math works thanks whoever is reading this lol
|
|
||||||
var fakeFramerate:Int = Math.round((1 / FlxG.elapsed) / 10);
|
|
||||||
|
|
||||||
public override function update(elapsed:Float):Void
|
public override function update(elapsed:Float):Void
|
||||||
{
|
{
|
||||||
this.y = MathUtil.coolLerp(y, targetY, 0.17);
|
this.y = MathUtil.coolLerp(y, targetY, 0.17);
|
||||||
|
|
||||||
if (isFlashing) flashingInt += 1;
|
if (isFlashing)
|
||||||
if (flashingInt % fakeFramerate >= Math.floor(fakeFramerate / 2)) title.color = 0xFF33ffff;
|
{
|
||||||
else
|
flashTick += elapsed;
|
||||||
title.color = FlxColor.WHITE;
|
if (flashTick >= 1 / flashFramerate)
|
||||||
|
{
|
||||||
|
flashTick %= 1 / flashFramerate;
|
||||||
|
title.color = (title.color == FlxColor.WHITE) ? 0xFF33ffff : FlxColor.WHITE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showLock():Void
|
public function showLock():Void
|
||||||
|
|
Loading…
Reference in a new issue