adding the possibility to pause/resume an animation

This commit is contained in:
Clément Le Bihan
2021-06-02 16:11:14 +02:00
parent f245fe727b
commit b3eae9ebdf
3 changed files with 24 additions and 3 deletions
@@ -8,10 +8,11 @@
namespace BBM
{
AnimationsComponent::AnimationsComponent(WAL::Entity &entity, RAY::ModelAnimations modelAnimation, int animIndex)
AnimationsComponent::AnimationsComponent(WAL::Entity &entity, RAY::ModelAnimations modelAnimation, int animIndex, bool play)
: WAL::Component(entity),
_modelAnimation(std::move(modelAnimation)),
_currentAnimIndex(animIndex)
_currentAnimIndex(animIndex),
_animDisabled(play)
{
this->_modelAnimation[this->_currentAnimIndex].setFrameCounter(0);
}
@@ -57,4 +58,14 @@ namespace BBM
{
this->_modelAnimation[this->_currentAnimIndex].incrementFrameCounter();
}
void AnimationsComponent::setAnimDisabled(bool disable)
{
this->_animDisabled = disable;
}
bool AnimationsComponent::isAnimDisabled() const
{
return this->_animDisabled;
}
}
@@ -18,6 +18,8 @@ namespace BBM
RAY::ModelAnimations _modelAnimation;
//! @brief The index of the
int _currentAnimIndex;
//! @brief Bool allowing to play pause an animation
bool _animDisabled;
public:
//! @inherit
WAL::Component *clone(WAL::Entity &entity) const override;
@@ -43,8 +45,14 @@ namespace BBM
//! @brief Increment the internal anim counter
void incCurrentAnimFrameCounter();
//! @brief Allow to play pause animations
void setAnimDisabled(bool disable);
//! @brief To know if the animation will be updated or not
bool isAnimDisabled() const;
//! @brief ctor entity and the path of the animation file
explicit AnimationsComponent(WAL::Entity &entity, RAY::ModelAnimations modelAnimation, int animIndex);
explicit AnimationsComponent(WAL::Entity &entity, RAY::ModelAnimations modelAnimation, int animIndex, bool play = true);
//! @brief copy ctor
AnimationsComponent(const AnimationsComponent &) = default;
//! @brief dtor