diff options
Diffstat (limited to 'examples/animation/sub-attaq/graphicsscene.cpp')
-rw-r--r-- | examples/animation/sub-attaq/graphicsscene.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/examples/animation/sub-attaq/graphicsscene.cpp b/examples/animation/sub-attaq/graphicsscene.cpp index 5dcc034..a66925c 100644 --- a/examples/animation/sub-attaq/graphicsscene.cpp +++ b/examples/animation/sub-attaq/graphicsscene.cpp @@ -50,6 +50,7 @@ #include "custompropertyanimation.h" #include "animationmanager.h" #include "qanimationstate.h" +#include "progressitem.h" //Qt #if defined(QT_EXPERIMENTAL_SOLUTION) @@ -117,6 +118,15 @@ GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode) surfaceItem->setPos(0,sealLevel() - surfaceItem->boundingRect().height()/2); addItem(surfaceItem); + //The item that display score and level + progressItem = new ProgressItem(backgroundItem); + + //We create the boat + boat = new Boat(); + addItem(boat); + boat->setPos(this->width()/2, sealLevel() - boat->size().height()); + boat->hide(); + //parse the xml that contain all data of the game QXmlStreamReader reader; QFile file(QDir::currentPath() + "/data.xml"); @@ -335,17 +345,17 @@ void GraphicsScene::clearScene() { foreach (SubMarine *sub,submarines) { sub->destroy(); - delete sub; + sub->deleteLater(); } foreach (Torpedo *torpedo,torpedos) { torpedo->destroy(); - delete torpedo; + torpedo->deleteLater(); } foreach (Bomb *bomb,bombs) { bomb->destroy(); - delete bomb; + bomb->deleteLater(); } submarines.clear(); @@ -354,10 +364,8 @@ void GraphicsScene::clearScene() AnimationManager::self()->unregisterAllAnimations(); - if (boat) { - delete boat; - boat = 0; - } + boat->stop(); + boat->hide(); } QGraphicsPixmapItem *GraphicsScene::addWelcomeItem(const QPixmap &pm) |