However, vibration does not work at all (since the beta 2 firmware).
connect(this,SIGNAL(allGhostsPicked()),this,SLOT(nextLevel()),Qt::QueuedConnection);
connect(this,SIGNAL(allGhostsPicked()),this,SLOT(nextLevel()),Qt::QueuedConnection);
pVibrateAction_ = new QAction(tr("Vibration effects"),this);
pVibrateAction_->setCheckable(true);
connect(pVibrateAction_,SIGNAL(toggled(bool)),this,SLOT(vibrationActivate(bool)));
pVibrateAction_ = new QAction(tr("Vibration effects"),this);
pVibrateAction_->setCheckable(true);
connect(pVibrateAction_,SIGNAL(toggled(bool)),this,SLOT(vibrationActivate(bool)));
autopauseTimer.setInterval(15*60*1000);
connect(&autopauseTimer,SIGNAL(timeout()),this,SLOT(turnPauseOn()));
autopauseTimer.setInterval(15*60*1000);
connect(&autopauseTimer,SIGNAL(timeout()),this,SLOT(turnPauseOn()));
+ vibrationAllowed_ = false;
pResourceSet_ = new ResourcePolicy::ResourceSet("game",this);
ResourcePolicy::VibraResource * pVibraResource = new ResourcePolicy::VibraResource();
pVibraResource->setOptional(false); //The only resource of the set, so no sense for it to be optional
pResourceSet_ = new ResourcePolicy::ResourceSet("game",this);
ResourcePolicy::VibraResource * pVibraResource = new ResourcePolicy::VibraResource();
pVibraResource->setOptional(false); //The only resource of the set, so no sense for it to be optional
connect(pShip,SIGNAL(pickingGhost(QGraphicsItem*)),this, SLOT(removeGhost(QGraphicsItem*)) );
connect(pShip,SIGNAL(droppingGhosts(int)),this,SLOT(ghostsDropped(int)));
connect(this,SIGNAL(vibrationActivated(bool)),pShip,SLOT(setVibrationActivate(bool)));
connect(pShip,SIGNAL(pickingGhost(QGraphicsItem*)),this, SLOT(removeGhost(QGraphicsItem*)) );
connect(pShip,SIGNAL(droppingGhosts(int)),this,SLOT(ghostsDropped(int)));
connect(this,SIGNAL(vibrationActivated(bool)),pShip,SLOT(setVibrationActivate(bool)));
+ if (vibrationAllowed_)
+ pShip->allowVibration(); //Vibration is disallowed by default so only allowing needs to be done explicitly
+ connect(pResourceSet_,SIGNAL(resourcesGranted(const QList< ResourcePolicy::ResourceType >)),pShip,SLOT(allowVibration()));
+ connect(pResourceSet_,SIGNAL(lostResources()),pShip,SLOT(disallowVibration()));
pShip->startMoving();
movingItems_.append(pShip);
connect(this,SIGNAL(pauseOn()),pShip,SLOT(stopMoving()));
pShip->startMoving();
movingItems_.append(pShip);
connect(this,SIGNAL(pauseOn()),pShip,SLOT(stopMoving()));
vibrationActivate(pVibrateAction_->isChecked()); //Vibration effects are lost without this
// qDebug() << pVibrateAction_->isChecked();
vibrationActivate(pVibrateAction_->isChecked()); //Vibration effects are lost without this
// qDebug() << pVibrateAction_->isChecked();
autopauseTimer.start(); //reset counting towards autopause
autopauseTimer.start(); //reset counting towards autopause
void SeaScene::resourcesAvailable()
{
qDebug() << "Resources available";
void SeaScene::resourcesAvailable()
{
qDebug() << "Resources available";
+ vibrationAllowed_ = true;
}
void SeaScene::resourcesLost()
{
qDebug() << "Resources lost";
}
void SeaScene::resourcesLost()
{
qDebug() << "Resources lost";
+ vibrationAllowed_ = false;
void pauseOff();
void vibrationActivated(bool on);
void pauseOff();
void vibrationActivated(bool on);
public slots:
/*! Places all needed items for a level to (re)start.
public slots:
/*! Places all needed items for a level to (re)start.
int levelScore_;
ResourcePolicy::ResourceSet * pResourceSet_;
int levelScore_;
ResourcePolicy::ResourceSet * pResourceSet_;
+ bool vibrationAllowed_;
shipImages_ = pixmapList;
ghostsAboard_ = 0;
vibrationActive_ = false;
shipImages_ = pixmapList;
ghostsAboard_ = 0;
vibrationActive_ = false;
+ vibrationAllowed_ = false;
}
bool Ship::handleCollisions()
}
bool Ship::handleCollisions()
+ if (vibrationActive_ && vibrationAllowed_)
{
// This is for fremantle
{
// This is for fremantle
{
vibrationActive_ = on;
}
{
vibrationActive_ = on;
}
+
+void Ship::allowVibration()
+{
+ vibrationAllowed_ = true;
+}
+
+void Ship::disallowVibration()
+{
+ vibrationAllowed_ = false;
+}
void setVibrationActivate(bool on);
void setVibrationActivate(bool on);
+ void allowVibration();
+
+ void disallowVibration();
+
+ bool vibrationAllowed_;
+