-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Transition effect to seperate class
- Loading branch information
Showing
15 changed files
with
521 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
#pragma once | ||
|
||
#include <bn_bgs_mosaic_actions.h> | ||
#include <bn_blending_actions.h> | ||
#include <bn_optional.h> | ||
#include <bn_sprites_mosaic_actions.h> | ||
|
||
namespace sym::effect | ||
{ | ||
|
||
/** | ||
* @brief Simple end-to-end transition | ||
* Manages all the actions including transparency, fade, intensity, and mosaic. | ||
* | ||
*/ | ||
class Transition | ||
{ | ||
public: | ||
/** | ||
* @brief Transition Type. | ||
* Keep in mind that FADE and other blendings cannot be enabled at the same time. | ||
* | ||
*/ | ||
enum class Types | ||
{ | ||
TRANSPARENCY = 1, | ||
FADE = 2, | ||
INTENSITY = 4, | ||
SPRITE_MOSAIC = 8, | ||
BG_MOSAIC = 16 | ||
}; | ||
enum class Direction | ||
{ | ||
IN, | ||
OUT | ||
}; | ||
enum class State | ||
{ | ||
NOT_READY, | ||
ONGOING, | ||
DONE | ||
}; | ||
|
||
Transition(Types types, Direction direction, int updateCount); | ||
|
||
~Transition(); | ||
|
||
/** | ||
* @brief Allocates transition actions & sets state to ONGOING. | ||
* You must call this function before using Transition. | ||
* | ||
* Calling Init() of the second transition object after calling Destroy() of the first transition object, | ||
* you can prevent having FADE and other blendings at the same time, | ||
* while keeping both Transition objects alive. | ||
* | ||
*/ | ||
void Init(); | ||
|
||
/** | ||
* @brief Updates transition actions. | ||
* you must check Done() first. | ||
* Because updating the finished action will break the game. | ||
* When transition is done, this function automatically calls Destroy() and sets state to DONE. | ||
* | ||
*/ | ||
void Update(); | ||
|
||
/** | ||
* @brief Disposes transition actions. | ||
* This function is automatically called when the transition is done. | ||
* Keep in mind that you have to manually reset the blending alpha. | ||
* | ||
*/ | ||
void Destroy(); | ||
|
||
/** | ||
* @brief Get the State object | ||
* | ||
* @return current state | ||
*/ | ||
State GetState() const | ||
{ | ||
return state_; | ||
} | ||
|
||
private: | ||
const Types types_; | ||
const Direction direction_; | ||
int updateCountDown_; | ||
|
||
State state_ = State::NOT_READY; | ||
|
||
bn::optional<bn::blending_transparency_alpha_to_action> transparencyAction_; | ||
bn::optional<bn::blending_fade_alpha_to_action> fadeAction_; | ||
bn::optional<bn::blending_intensity_alpha_to_action> intensityAction_; | ||
bn::optional<bn::sprites_mosaic_stretch_to_action> spriteMosaicAction_; | ||
bn::optional<bn::bgs_mosaic_stretch_to_action> bgMosaicAction_; | ||
}; | ||
|
||
inline Transition::Types operator|(Transition::Types t1, Transition::Types t2) | ||
{ | ||
return static_cast<Transition::Types>(static_cast<int>(t1) | static_cast<int>(t2)); | ||
} | ||
|
||
inline Transition::Types operator&(Transition::Types t1, Transition::Types t2) | ||
{ | ||
return static_cast<Transition::Types>(static_cast<int>(t1) & static_cast<int>(t2)); | ||
} | ||
|
||
} // namespace sym::effect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include <bn_sprite_text_generator.h> | ||
|
||
namespace sym::global | ||
{ | ||
|
||
struct TextGen | ||
{ | ||
bn::sprite_text_generator* hangeul; | ||
bn::sprite_text_generator* latin; | ||
|
||
TextGen(bn::sprite_text_generator* hg, bn::sprite_text_generator* lt) : hangeul(hg), latin(lt) | ||
{ | ||
} | ||
}; | ||
|
||
extern TextGen* textGenPtr_g; | ||
|
||
} // namespace sym::global |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#pragma once | ||
|
||
#include "scene_Scene.h" | ||
|
||
#include <bn_array.h> | ||
#include <bn_optional.h> | ||
#include <bn_regular_bg_ptr.h> | ||
#include <bn_sprite_ptr.h> | ||
|
||
#include "effect_Transition.h" | ||
|
||
namespace sym::scene | ||
{ | ||
|
||
class Title final : public Scene | ||
{ | ||
public: | ||
Title(); | ||
~Title() = default; | ||
[[nodiscard]] bn::optional<Type> Update() final; | ||
|
||
private: | ||
bn::array<bn::sprite_ptr, 2> cursor_; | ||
bn::regular_bg_ptr bg_; | ||
effect::Transition fadeIn_; | ||
effect::Transition fadeOut_; | ||
|
||
static constexpr int CURSOR_HORIZONTAL_OFFSET = 30; | ||
static constexpr int BUTTON_WIDTH = 20; | ||
static constexpr int FADE_IN_UPDATE_COUNT = 30; | ||
static constexpr int FADE_OUT_UPDATE_COUNT = 30; | ||
}; | ||
|
||
} // namespace sym::scene |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.