summaryrefslogtreecommitdiffstats
path: root/pacman-c++/animationmanager.cpp
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2011-04-04 11:27:54 +0200
committermanuel <manuel@mausz.at>2011-04-04 11:27:54 +0200
commita35824a3319ae9c304263185c4efc449e2c2cf73 (patch)
treef769dc8e8e06265594b2f0e5bda47163428c47be /pacman-c++/animationmanager.cpp
parent2a2c8d3b30e99e2bd636891a2eef27c0f35dcbc3 (diff)
downloadfoop-a35824a3319ae9c304263185c4efc449e2c2cf73.tar.gz
foop-a35824a3319ae9c304263185c4efc449e2c2cf73.tar.bz2
foop-a35824a3319ae9c304263185c4efc449e2c2cf73.zip
added simple pacman animation
Diffstat (limited to 'pacman-c++/animationmanager.cpp')
-rw-r--r--pacman-c++/animationmanager.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/pacman-c++/animationmanager.cpp b/pacman-c++/animationmanager.cpp
new file mode 100644
index 0000000..69bec53
--- /dev/null
+++ b/pacman-c++/animationmanager.cpp
@@ -0,0 +1,56 @@
1#include "animationmanager.h"
2#include <QtCore/QAbstractAnimation>
3#include <QtCore/QDebug>
4
5// the universe's only animation manager
6AnimationManager *AnimationManager::instance = 0;
7
8AnimationManager::AnimationManager()
9{
10}
11
12AnimationManager *AnimationManager::self()
13{
14 if (!instance)
15 instance = new AnimationManager;
16 return instance;
17}
18
19void AnimationManager::registerAnimation(QAbstractAnimation *anim)
20{
21 QObject::connect(anim, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterAnimation_helper(QObject*)));
22 animations.append(anim);
23}
24
25void AnimationManager::unregisterAnimation_helper(QObject *obj)
26{
27 unregisterAnimation(static_cast<QAbstractAnimation*>(obj));
28}
29
30void AnimationManager::unregisterAnimation(QAbstractAnimation *anim)
31{
32 QObject::disconnect(anim, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterAnimation_helper(QObject*)));
33 animations.removeAll(anim);
34}
35
36void AnimationManager::unregisterAllAnimations()
37{
38 animations.clear();
39}
40
41void AnimationManager::pauseAll()
42{
43 foreach (QAbstractAnimation* animation, animations)
44 {
45 if (animation->state() == QAbstractAnimation::Running)
46 animation->pause();
47 }
48}
49void AnimationManager::resumeAll()
50{
51 foreach (QAbstractAnimation* animation, animations)
52 {
53 if (animation->state() == QAbstractAnimation::Paused)
54 animation->resume();
55 }
56}