-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimationSystem.cpp
More file actions
33 lines (23 loc) · 885 Bytes
/
AnimationSystem.cpp
File metadata and controls
33 lines (23 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//
// Created by Fabien on 17/01/2016.
//
#include "AnimationSystem.hpp"
void AnimationSystem::update(entityx::EntityManager &es, entityx::EventManager &events, entityx::TimeDelta dt)
{
es.each<Animable>([dt](entityx::Entity entity, Animable& animable) {
Animation* currentAnimation = animable.animations[animable.current].get();
if(currentAnimation != nullptr)
{
currentAnimation->displayTime += dt;
if(currentAnimation->displayTime > currentAnimation->frameTime)
{
currentAnimation->displayTime = 0;
currentAnimation->current++;
if(currentAnimation->current == currentAnimation->animationRects.end())
{
currentAnimation->current = currentAnimation->animationRects.begin();
}
}
}
});
}