From 8903be3f604b3170ed7bde043c863b8c7970d185 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Heli=20Hyv=C3=A4ttinen?= Date: Mon, 26 Sep 2011 21:57:31 +0300 Subject: [PATCH] Vibration now works. This time real vibration, not just "knak" sound. --- ship.cpp | 20 +++++++++++++++----- ship.h | 7 +++++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/ship.cpp b/ship.cpp index 6c92db0..261d50d 100644 --- a/ship.cpp +++ b/ship.cpp @@ -25,7 +25,7 @@ #include #include #include -#include + @@ -39,8 +39,20 @@ Ship::Ship(QList 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 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 --- a/ship.h +++ b/ship.h @@ -24,6 +24,7 @@ #define SHIP_H #include "orientationcontrolledgraphicspixmapobject.h" +#include class Ship : public OrientationControlledGraphicsPixmapObject { @@ -32,6 +33,8 @@ class Ship : public OrientationControlledGraphicsPixmapObject public: explicit Ship(QList 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_; + }; -- 1.7.9.5