Moved global.* to mastersettings.*, and converted many error messages to use the...
[tagua/yd.git] / src / mainanimation.cpp
blob7a19ab0f3e6d368e8fb2e2d94f0fe5aa5ad326fe
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #include "mainanimation.h"
13 using namespace boost;
15 MainAnimation::MainAnimation(double speed)
16 : AnimationGroup(true)
17 , m_translate(0)
18 , m_speed(speed) {
19 m_active = true;
20 m_time.start();
21 m_timer.start(20);
23 connect(&m_timer, SIGNAL(timeout()), this, SLOT(tick()));
26 void MainAnimation::addAnimation(const shared_ptr<Animation>& a) {
27 AnimationGroup::addPostAnimation(a);
28 tick();
31 void MainAnimation::stop() {
32 AnimationGroup::stop();
35 void MainAnimation::tick() {
36 animationAdvance( int(m_time.elapsed()*m_speed) + m_translate);
39 void MainAnimation::setSpeed(double speed) {
40 int e = m_time.elapsed();
41 m_translate = int((e*m_speed + m_translate) - e*speed);
42 m_speed = speed;
45 void MainAnimation::setDelay(int delay) {
46 m_timer.setInterval(delay);