35 lines
1.0 KiB
C++
35 lines
1.0 KiB
C++
// Copyright (c) 2022 Dominic Masters
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
#include "VisualNovelFadeEvent.hpp"
|
|
|
|
using namespace Dawn;
|
|
|
|
VisualNovelFadeEvent::VisualNovelFadeEvent(
|
|
VisualNovelManager *man,
|
|
struct Color color,
|
|
bool_t fadeIn,
|
|
easefunction_t *ease,
|
|
float_t duration
|
|
) : VisualNovelSimpleAnimationEvent(man, &duration) {
|
|
this->color = color;
|
|
this->fadeIn = fadeIn;
|
|
this->duration = duration;
|
|
this->simpleAnimation.easing = ease;
|
|
}
|
|
|
|
void VisualNovelFadeEvent::onStart(IVisualNovelEvent *previous) {
|
|
VisualNovelSimpleAnimationEvent::onStart(previous);
|
|
|
|
this->simpleAnimation = SimpleAnimation<float_t>(&this->manager->fader->color.a);
|
|
this->manager->fader->color = this->color;
|
|
this->manager->fader->color.a = this->fadeIn ? 0.0f : 1.0f;
|
|
this->simpleAnimation.addKeyframe(
|
|
0.0f, this->fadeIn ? 0.0f : 1.0f
|
|
);
|
|
this->simpleAnimation.addKeyframe(
|
|
this->duration, this->fadeIn ? 1.0f : 0.0f
|
|
);
|
|
} |