From ef485758306baa58b6b21c2f11f809792f79d123 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Heli=20Hyv=C3=A4ttinen?= Date: Sat, 22 Oct 2011 22:57:57 +0300 Subject: [PATCH] Fixed ship speed rising bug Speed seems to remain steady now. No longer uses animation for ship movement, hopping not seen since. Accelometer sensitivity set to 12 degree treshold (instead of 3). Ship no longer moves when the device is lying on a table. Ship still too slow, needs to be adjusted. --- orientationcontrolledgraphicspixmapobject.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/orientationcontrolledgraphicspixmapobject.cpp b/orientationcontrolledgraphicspixmapobject.cpp index d5bc388..0276a25 100644 --- a/orientationcontrolledgraphicspixmapobject.cpp +++ b/orientationcontrolledgraphicspixmapobject.cpp @@ -37,7 +37,8 @@ OrientationControlledGraphicsPixmapObject::OrientationControlledGraphicsPixmapOb { rotationReadingInitialized_ = false; - rotationReadingTimer_.setInterval(100); + rotationReadingTimer_.setInterval(35); + connect(&rotationReadingTimer_,SIGNAL(timeout()),this,SLOT(readRotationSensor())); connect(&rotationSensor_,SIGNAL(readingChanged()),this,SLOT(rotationSensorReady())); @@ -98,8 +99,8 @@ void OrientationControlledGraphicsPixmapObject::readRotationSensor() // int newy = y() + deltay/15; //this is for Harmattan - int newx = x() + deltax/3; - int newy = y() + deltay/3; + int newx = x() + deltax/12; + int newy = y() + deltay/12; // qDebug() << sceneRectangle.left() << sceneRectangle.right(); @@ -110,12 +111,13 @@ void OrientationControlledGraphicsPixmapObject::readRotationSensor() int finalY = qBound(sceneRectangle.top(),newy,sceneRectangle.bottom()-pixmap().height()); + setPos(QPointF(finalX,finalY)); - QPropertyAnimation * animation = new QPropertyAnimation(this,"pos",this); - animation->setDuration(60); //milliseconds - animation->setStartValue(pos()); - animation->setEndValue( QPointF(finalX,finalY)); - animation->start(QAbstractAnimation::DeleteWhenStopped); +// QPropertyAnimation * animation = new QPropertyAnimation(this,"pos",this); +// animation->setDuration(60); //milliseconds +// animation->setStartValue(pos()); +// animation->setEndValue( QPointF(finalX,finalY)); +// animation->start(QAbstractAnimation::DeleteWhenStopped); //handle collisions and move back to the original position if false returned @@ -153,7 +155,6 @@ void OrientationControlledGraphicsPixmapObject::rotationSensorReady() if (!rotationReadingInitialized_) { - connect(&rotationReadingTimer_,SIGNAL(timeout()),this,SLOT(readRotationSensor())); rotationReadingInitialized_ = true; rotationReadingTimer_.start(); } -- 1.7.9.5