* Lua Improvments * fix * fix 2 * fix 3 * fix 4 * fix 5 * fix 6 * Fix 7, please action dont fail * done * done 2 * done 3 * final * last fix * please last fix final * add `curSection` on lua * ready for pr * oops * oop2 * Lua Improvements 2 * Update Project.xml * fixed `lastCalledScript` * Attempt Fix 2 * Attempt fix 3 * shit * done i think * fuck * fuck 2
78 lines
1.9 KiB
Haxe
78 lines
1.9 KiB
Haxe
package;
|
|
|
|
import flixel.util.FlxGradient;
|
|
|
|
class CustomFadeTransition extends MusicBeatSubstate {
|
|
public static var finishCallback:Void->Void;
|
|
var isTransIn:Bool = false;
|
|
var transBlack:FlxSprite;
|
|
var transGradient:FlxSprite;
|
|
|
|
var duration:Float;
|
|
public function new(duration:Float, isTransIn:Bool)
|
|
{
|
|
this.duration = duration;
|
|
this.isTransIn = isTransIn;
|
|
super();
|
|
}
|
|
|
|
override function create()
|
|
{
|
|
cameras = [FlxG.cameras.list[FlxG.cameras.list.length-1]];
|
|
var width:Int = Std.int(FlxG.width / Math.max(camera.zoom, 0.001));
|
|
var height:Int = Std.int(FlxG.height / Math.max(camera.zoom, 0.001));
|
|
transGradient = FlxGradient.createGradientFlxSprite(1, height, (isTransIn ? [0x0, FlxColor.BLACK] : [FlxColor.BLACK, 0x0]));
|
|
transGradient.scale.x = width;
|
|
transGradient.updateHitbox();
|
|
transGradient.scrollFactor.set();
|
|
transGradient.screenCenter(X);
|
|
add(transGradient);
|
|
|
|
transBlack = new FlxSprite().makeGraphic(1, 1, FlxColor.BLACK);
|
|
transBlack.scale.set(width, height + 400);
|
|
transBlack.updateHitbox();
|
|
transBlack.scrollFactor.set();
|
|
transBlack.screenCenter(X);
|
|
add(transBlack);
|
|
|
|
if(isTransIn)
|
|
transGradient.y = transBlack.y - transBlack.height;
|
|
else
|
|
transGradient.y = -transGradient.height;
|
|
|
|
super.create();
|
|
}
|
|
|
|
override function update(elapsed:Float) {
|
|
super.update(elapsed);
|
|
|
|
final height:Float = FlxG.height * Math.max(camera.zoom, 0.001);
|
|
final targetPos:Float = transGradient.height + 50 * Math.max(camera.zoom, 0.001);
|
|
if(duration > 0)
|
|
transGradient.y += (height + targetPos) * elapsed / duration;
|
|
else
|
|
transGradient.y = (targetPos) * elapsed;
|
|
|
|
if(isTransIn)
|
|
transBlack.y = transGradient.y + transGradient.height;
|
|
else
|
|
transBlack.y = transGradient.y - transBlack.height;
|
|
|
|
if(transGradient.y >= targetPos)
|
|
{
|
|
close();
|
|
}
|
|
}
|
|
|
|
// Don't delete this
|
|
override function close():Void
|
|
{
|
|
super.close();
|
|
|
|
if(finishCallback != null)
|
|
{
|
|
finishCallback();
|
|
finishCallback = null;
|
|
}
|
|
}
|
|
} |