Vibration now works.
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Mon, 26 Sep 2011 18:57:31 +0000 (21:57 +0300)
committerHeli Hyvättinen <heli.hyvattinen@kymp.net>
Mon, 26 Sep 2011 18:57:31 +0000 (21:57 +0300)
This time real vibration, not just "knak" sound.

ship.cpp
ship.h

index 6c92db0..261d50d 100644 (file)
--- a/ship.cpp
+++ b/ship.cpp
@@ -25,7 +25,7 @@
 #include <QDebug>
 #include <QDBusMessage>
 #include <QDBusConnection>
-#include <QFeedbackHapticsEffect>
+
 
 
 
@@ -39,8 +39,20 @@ Ship::Ship(QList<QPixmap> pixmapList, QGraphicsItem *parent) :
     ghostsAboard_ = 0;
     vibrationActive_ = false;
     vibrationAllowed_ = false;
+
+    pVibrationEffect_ = new QFeedbackHapticsEffect();
+    pVibrationEffect_->setDuration(1000);
+    pVibrationEffect_->setIntensity(1.0);
+
+}
+
+Ship::~Ship()
+{
+    if (pVibrationEffect_)
+      delete pVibrationEffect_;
 }
 
+
 bool Ship::handleCollisions()
 {
     QList<QGraphicsItem*>  collidesList = collidingItems();
@@ -118,10 +130,8 @@ void Ship::dropAllGhosts()
 
         //This is for Harmattan
 
-        QFeedbackHapticsEffect vibrationEffect;
-        vibrationEffect.setDuration(1000);
-        vibrationEffect.setIntensity(1.0);
-        vibrationEffect.start();
+        pVibrationEffect_->start();
+
 
     }
 }
diff --git a/ship.h b/ship.h
index 6aa2cc6..ffdbfb7 100644 (file)
--- a/ship.h
+++ b/ship.h
@@ -24,6 +24,7 @@
 #define SHIP_H
 
 #include "orientationcontrolledgraphicspixmapobject.h"
+#include <QFeedbackHapticsEffect>
 
 class Ship : public OrientationControlledGraphicsPixmapObject
 {
@@ -32,6 +33,8 @@ class Ship : public OrientationControlledGraphicsPixmapObject
 public:
     explicit Ship(QList<QPixmap> pixmapList, QGraphicsItem *parent = 0);
 
+    virtual ~Ship();
+
 signals:
 
     /*! Emitted when a ghost is hit */
@@ -53,8 +56,6 @@ public slots:
     void disallowVibration();
 
 protected:
-
-protected:
     bool handleCollisions();
 
     void updateShipImage();
@@ -67,6 +68,8 @@ protected:
 
     bool vibrationAllowed_;
 
+    QFeedbackHapticsEffect * pVibrationEffect_;
+
 
 };