Newer
Older
lostmynuts / shared / js / Engine / GameScreen / ScreenTransitionFade.js
Engine.ScreenTransitionFade = class extends Engine.ScreenTransition
{
	constructor()
	{
		super();
	}

	init(from /*Drawable*/, to /*Drawable*/)
	{
		this.from = from;
		this.to = to;
	}

	transitionOut(transitionComplete /*Action*/)
	{
		var parent = this.to.parent;
		if (parent)
		{
			parent.removeChild(this.to);
			parent.addChild(this.to);
		}
		
		this.resetTransition();
		this.screenTransTweenA = new SEngine.impleTween((v) => { this.to.alpha = v; }, Engine.SimpleTween.quadEaseOut, 0, 1, 0.5, false);
		this.screenTransTweenA.onFinish = transitionComplete;
		this.from.alpha = 1;
		this.to.alpha = 0;
	}

	transitionIn(transitionComplete /*Action*/)
	{
		
		var parent = this.to.parent;
		if (parent)
		{
			parent.removeChild(this.to);
			parent.addChild(this.to);
		}
		
		this.resetTransition();
		this.screenTransTweenA = new Engine.SimpleTween((v) => { this.to.alpha = v; }, Engine.SimpleTween.quadEaseOut, 0, 1, 0.5, false);
		this.screenTransTweenA.onFinish = transitionComplete; 
		this.from.alpha = 1;
		this.to.alpha = 0;
	}

}