SVN commit 1191705 by majewsky: Decouple bumper animation from scene loop. M +6 -22 game.cpp M +3 -3 game.h --- trunk/KDE/kdegames/kolf/game.cpp #1191704:1191705 @@ -1034,29 +1034,8 @@ const int diameter = 20; setSize(QSizeF(diameter, diameter)); setZValue(-25); - - count = 0; - setAnimated(false); } -void Bumper::advance(int phase) -{ - if(!isAnimated()) - return; - - QGraphicsItem::advance(phase); - - if (phase == 1) - { - if (++count > 2) - { - count = 0; - setSpriteKey(QLatin1String("bumper_off")); - setAnimated(false); - } - } -} - bool Bumper::collision(Ball *ball, long int /*id*/) { double maxSpeed = ball->getMaxBumperBounceSpeed(); @@ -1075,11 +1054,16 @@ ball->setState(Rolling); setSpriteKey(QLatin1String("bumper_on")); - setAnimated(true); + QTimer::singleShot(100, this, SLOT(turnBumperOff())); return true; } +void Bumper::turnBumperOff() +{ + setSpriteKey(QLatin1String("bumper_off")); +} + ///////////////////////// Cup::Cup(QGraphicsItem * parent) --- trunk/KDE/kdegames/kolf/game.h #1191704:1191705 @@ -251,13 +251,13 @@ class Bumper : public EllipticalCanvasItem { +Q_OBJECT public: Bumper(QGraphicsItem *parent); - virtual void advance(int phase); virtual bool collision(Ball *ball, long int id); -private: - int count; +public Q_SLOTS: + void turnBumperOff(); }; class Cup : public EllipticalCanvasItem