generated from sigonasr2/CPlusPlusProjectTemplate
Fade in and out added
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
5fcdbc1b80
commit
50103f7032
Binary file not shown.
23
cutscene.h
23
cutscene.h
@ -16,7 +16,8 @@ enum class ActionType{
|
|||||||
PAN_CAMERA,
|
PAN_CAMERA,
|
||||||
CREATE_OBJECTS,
|
CREATE_OBJECTS,
|
||||||
CLEANUP,
|
CLEANUP,
|
||||||
SET_FLAG_WHEN_CUTSCENE_ENDS
|
SET_FLAG_WHEN_CUTSCENE_ENDS,
|
||||||
|
FADE,
|
||||||
};
|
};
|
||||||
|
|
||||||
class CutsceneAction{
|
class CutsceneAction{
|
||||||
@ -89,6 +90,26 @@ class SetFlagWhenCutsceneEnds:public CutsceneAction{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Fade:public CutsceneAction{
|
||||||
|
private:
|
||||||
|
bool fadeIn=true; //If false, it fades out instead.
|
||||||
|
double fadeSpd=0;
|
||||||
|
public:
|
||||||
|
//If false, it fades out instead.
|
||||||
|
Fade(bool fadeIn=false,double fadeSpd=1) {
|
||||||
|
this->fadeIn=fadeIn;
|
||||||
|
this->fadeSpd=fadeSpd;
|
||||||
|
}
|
||||||
|
ActionType GetActionType() override{return ActionType::FADE;}
|
||||||
|
//If false, then it means we need to fade out instead.
|
||||||
|
bool FadeIn() {
|
||||||
|
return fadeIn;
|
||||||
|
}
|
||||||
|
double GetFadeSpd() {
|
||||||
|
return fadeSpd;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
To use this class, specify multiple actions back-to-back, filling their appropriate arguments.
|
To use this class, specify multiple actions back-to-back, filling their appropriate arguments.
|
||||||
|
|
||||||
|
3
flags.h
3
flags.h
@ -8,8 +8,7 @@ enum class Flag:int{
|
|||||||
|
|
||||||
|
|
||||||
template <typename Enumeration>
|
template <typename Enumeration>
|
||||||
auto flagint(Enumeration const value)
|
auto flagint(Enumeration const value) -> typename std::underlying_type<Enumeration>::type
|
||||||
-> typename std::underlying_type<Enumeration>::type
|
|
||||||
{
|
{
|
||||||
return static_cast<typename std::underlying_type<Enumeration>::type>(value);
|
return static_cast<typename std::underlying_type<Enumeration>::type>(value);
|
||||||
}
|
}
|
16
main.cpp
16
main.cpp
@ -182,6 +182,8 @@ public:
|
|||||||
LoadMap(MAP_ONETT);
|
LoadMap(MAP_ONETT);
|
||||||
|
|
||||||
TestCutscene=new Cutscene({
|
TestCutscene=new Cutscene({
|
||||||
|
(CutsceneAction*)new Fade(),
|
||||||
|
(CutsceneAction*)new Fade(true),
|
||||||
(CutsceneAction*)new SetFlagWhenCutsceneEnds(Flag::TEST_FLAG1),
|
(CutsceneAction*)new SetFlagWhenCutsceneEnds(Flag::TEST_FLAG1),
|
||||||
(CutsceneAction*)new PanCamera({128,128},BOTH),
|
(CutsceneAction*)new PanCamera({128,128},BOTH),
|
||||||
(CutsceneAction*)new PanCamera({128,0},BOTH),
|
(CutsceneAction*)new PanCamera({128,0},BOTH),
|
||||||
@ -291,6 +293,20 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
|||||||
CurrentCutscene=nullptr;
|
CurrentCutscene=nullptr;
|
||||||
CurrentAction=ActionType::NONE;
|
CurrentAction=ActionType::NONE;
|
||||||
}break;
|
}break;
|
||||||
|
case ActionType::FADE:{
|
||||||
|
if (((Fade*)CurrentCutscene->GetAction())->FadeIn()&&CUTSCENE_FADE_VALUE>0) {
|
||||||
|
CUTSCENE_FADE_VALUE=std::clamp(CUTSCENE_FADE_VALUE-((Fade*)CurrentCutscene->GetAction())->GetFadeSpd(),0.0,255.0);
|
||||||
|
if (CUTSCENE_FADE_VALUE==0) {
|
||||||
|
CurrentCutscene->AdvanceAction();
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (!((Fade*)CurrentCutscene->GetAction())->FadeIn()&&CUTSCENE_FADE_VALUE<255) {
|
||||||
|
CUTSCENE_FADE_VALUE=std::clamp(CUTSCENE_FADE_VALUE+((Fade*)CurrentCutscene->GetAction())->GetFadeSpd(),0.0,255.0);
|
||||||
|
if (CUTSCENE_FADE_VALUE==255) {
|
||||||
|
CurrentCutscene->AdvanceAction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user