feat(anim): cardinal WEST i flip totalment governat pel motor d'animació
This commit is contained in:
1 parent
9dc7ff0da3
commit
72384c3113
15 files changed
+183
-182
No files matched your search
@@ -4,9 +4,14 @@
|
||||
#include <utility>
|
||||
|
||||
AnimationComponent::AnimationComponent(std::vector<int> frames, float fps, bool loop)
|
||||
: AnimationComponent(std::move(frames), fps, loop, false, false) {}
|
||||
|
||||
AnimationComponent::AnimationComponent(std::vector<int> frames, float fps, bool loop, bool flip_h, bool flip_v)
|
||||
: frames_(std::move(frames)),
|
||||
fps_(fps > 0.0F ? fps : 1.0F),
|
||||
loop_(loop) {
|
||||
loop_(loop),
|
||||
flip_h_(flip_h),
|
||||
flip_v_(flip_v) {
|
||||
// Una animació d'1 sol frame amb loop=false és una animació que ja s'ha
|
||||
// acabat de reproduir: no hi ha cap transició per mostrar. Marcant-la
|
||||
// com a completada des de l'inici permet als consumidors (p.ex. Door)
|
||||
@@ -46,3 +51,9 @@ auto AnimationComponent::currentFrame() const -> int {
|
||||
if (frames_.empty()) { return 0; }
|
||||
return frames_[static_cast<std::size_t>(current_)];
|
||||
}
|
||||
|
||||
auto AnimationComponent::flipMode() const -> SDL_FlipMode {
|
||||
if (flip_h_) { return SDL_FLIP_HORIZONTAL; }
|
||||
if (flip_v_) { return SDL_FLIP_VERTICAL; }
|
||||
return SDL_FLIP_NONE;
|
||||
}
|
||||
Reference in new issue
Block a user