Files
WickedEngine/WickedEngine/wiFadeManager.h
T
2017-05-03 17:02:00 +02:00

49 lines
779 B
C++

#pragma once
#include "CommonInclude.h"
#include "wiColor.h"
#include "wiTimer.h"
#include "wiMath.h"
#include <functional>
class wiFadeManager
{
public:
float opacity;
int frame, targetFrames;
enum FADE_STATE
{
FADE_IN, // no fade -> faded
FADE_MID, // completely faded
FADE_OUT, // faded -> no fade
FADE_FINISHED,
} state;
wiColor color;
std::function<void()> onFade;
wiFadeManager()
{
Clear();
}
void Clear();
void Start(int targetFrames, const wiColor& color, std::function<void()> onFadeFunction)
{
this->targetFrames = targetFrames;
this->color = color;
frame = 0;
state = FADE_IN;
onFade = onFadeFunction;
}
void Update();
bool IsFaded()
{
return state == FADE_MID;
}
bool IsActive()
{
return state != FADE_FINISHED;
}
};