Continued refactoring.
[tagua/yd.git] / src / mainanimation.cpp
blob115024254730602ba85afa84355d0a31eb07feb3
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);
49 #include "mainanimation.moc"