Dawn/archive/AnimationController.cpp

32 lines
818 B
C++

// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "AnimationController.hpp"
#include "game/DawnGame.hpp"
using namespace Dawn;
AnimationController::AnimationController(SceneItem *item) :
SceneItemComponent(item)
{
}
void AnimationController::addAnimation(Animation *animation) {
assertNotNull(animation, "AnimationController::addAnimation: Animation cannot be null");
this->animations.push_back(animation);
}
void AnimationController::onStart() {
SceneItemComponent::onStart();
useEvent([&](float_t delta){
auto it = this->animations.begin();
while(it != this->animations.end()) {
(*it)->tick(delta);
++it;
}
}, getScene()->eventSceneUnpausedUpdate);
}