Engine.EffectGlowBoxFlash = class extends Engine.Drawable
{
//private int xFeathering = 30;
//private int yFeathering = 33;
constructor()
{
super();
this.glowBoxWhite = new Engine.Drawable("GlowBox_Corner");
this.glowBoxColor = new Engine.Drawable("GlowBox_Corner");
this.layoutWidth = 0;
this.layoutHeight = 0;
this.speedMult = 1;
this.totalTime = 0;
this.onFinish = null;
this.currentIndex = 0;
this.tween = new Engine.SimpleTween();
this.alphaTargets = [0, 1, 0.38, 0];
this.glowBoxWhite.setNineRect(0.45, 0.45, 0.5, 0.5);
this.glowBoxColor.setNineRect(0.45, 0.45, 0.5, 0.5);
this.glowBoxWhite.additive = true;
this.glowBoxColor.additive = true;
this.addChild(this.glowBoxWhite);
this.addChild(this.glowBoxColor);
this.glowBoxColor.tint = Colors.blue;
}
init(time /*float*/, width /*int*/, height /*int*/, c /*Color?*/, xFeathering /*int*/, yFeathering /*int*/)
{
if (c === undefined) c = null;
if (xFeathering === undefined) xFeathering = 30;
if (yFeathering === undefined) yFeathering = 33;
if (width < 75)
{
this.glowBoxWhite.loadFromGraphicName("GlowBox_CornerSmall");
this.glowBoxColor.loadFromGraphicName("GlowBox_CornerSmall");
}
else
{
this.glowBoxWhite.loadFromGraphicName("GlowBox_Corner");
this.glowBoxColor.loadFromGraphicName("GlowBox_Corner");
}
this.glowBoxWhite.x = -xFeathering;
this.glowBoxWhite.y = -yFeathering;
this.glowBoxWhite.width = width + (xFeathering * 2);
this.glowBoxWhite.height = height + (yFeathering * 2);
this.glowBoxColor.x = this.glowBoxWhite.x;
this.glowBoxColor.y = this.glowBoxWhite.y;
this.glowBoxColor.width = this.glowBoxWhite.width;
this.glowBoxColor.height = this.glowBoxWhite.height;
this.speedMult = time / 0.7;
this.glowBoxWhite.alpha = this.alphaTargets[0];
this.glowBoxColor.alpha = this.alphaTargets[0];
if (c != null)
{
this.setGlowColor(c);
}
}
setGlowColor(c /*Color*/)
{
this.glowBoxColor.tint = c;
}
go()
{
this.currentIndex = 1;
this.tween.init((v) => this.animateFilterUpdate(v), Engine.SimpleTween.quadEaseIn, 0, 1, 0.2 * this.speedMult);
this.tween.onFinish = () => this.flashFadeInMid();
}
flashFadeInMid()
{
this.currentIndex = 2;
this.tween.init((v) => this.animateFilterUpdate(v), Engine.SimpleTween.quadEaseIn, 0, 1, 0.2 * this.speedMult);
this.tween.onFinish = () => this.returnFilterToNormal();
}
returnFilterToNormal()
{
this.currentIndex = 3;
this.tween.init((v) => this.animateFilterUpdate(v), Engine.SimpleTween.quadEaseIn, 0, 1, 0.3 * this.speedMult);
this.tween.onFinish = () => this.finished();
}
finished()
{
if (this.onFinish != null) this.onFinish();
}
animateFilterUpdate(value /*float*/)
{
var start = this.alphaTargets[this.currentIndex - 1];
var end = this.alphaTargets[this.currentIndex];
this.glowBoxWhite.alpha = start + value * (end - start);
this.glowBoxColor.alpha = start + value * (end - start);
}
}