Added autopause to changelog
[ghostsoverboard] / timercontrolledgraphicspixmapobject.cpp
index 56913f6..52fb616 100644 (file)
@@ -29,13 +29,14 @@ TimerControlledGraphicsPixmapObject::TimerControlledGraphicsPixmapObject(QPixmap
     QObject(), QGraphicsPixmapItem(pixmap, parent)
 {
     setSpeed(speed);
-    direction_ = S;
+    changeDirection();
     connect(&timer_,SIGNAL(timeout()),this,SLOT(move()));
 }
 
 void TimerControlledGraphicsPixmapObject::startMoving()
 {
-    timer_.start();
+    if (!stoppedBecauseInvalidTime_)
+        timer_.start();
 }
 
 void TimerControlledGraphicsPixmapObject::stopMoving()
@@ -45,9 +46,17 @@ void TimerControlledGraphicsPixmapObject::stopMoving()
 
 void TimerControlledGraphicsPixmapObject::setSpeed(int speed)
 {
-    timer_.setInterval(1000/speed); //converts from pixels in second to milliseconds per pixel
+    if (speed >0)
+    {
+        timer_.setInterval(1000/speed); //converts from pixels in second to milliseconds per pixel
+        stoppedBecauseInvalidTime_ = false;
+     }
+    else
+        stoppedBecauseInvalidTime_ = true;
+        timer_.stop();
 }
 
+
 void TimerControlledGraphicsPixmapObject::move()
 {