SeaScene::SeaScene(QObject *parent) :
QGraphicsScene(parent)
{
+ paused_ = false;
+ screenLitKeeper_.keepScreenLit(true);
+
//set background
QPixmap waves (":/pix/meri.png");
qsrand(QTime::currentTime().msec()+2); //+2 to avoid setting it to 1
+
+
}
void SeaScene::setupMap(int ghosts, int rocks, int octopuses)
addItem(pOctopus);
pOctopus->startMoving();
movingItems_.append(pOctopus);
+ connect(this,SIGNAL(pauseOn()),pOctopus,SLOT(stopMoving()));
+ connect(this,SIGNAL(pauseOff()),pOctopus,SLOT(startMoving()));
delete pPosition;
}
connect(pShip,SIGNAL(droppingGhosts(int)),this,SLOT(ghostsDropped(int)));
pShip->startMoving();
movingItems_.append(pShip);
+ connect(this,SIGNAL(pauseOn()),pShip,SLOT(stopMoving()));
+ connect(this,SIGNAL(pauseOff()),pShip,SLOT(startMoving()));
delete pPosition;
}
spreadGhosts(ghosts);
}
+
+void SeaScene::pause(bool paused)
+{
+ // qDebug() << "pause pressed " << paused;
+ if (paused_ == paused)
+ return;
+
+ paused_ = paused;
+
+ if (paused == false)
+ {
+ // qDebug() << "starting to move again";
+ emit pauseOff();
+ screenLitKeeper_.keepScreenLit(true);
+ }
+
+ else
+ {
+ // qDebug("about to stop movement");
+ emit pauseOn();
+ screenLitKeeper_.keepScreenLit(false);
+ }
+}