From: Heli Hyvättinen Date: Mon, 6 Jun 2011 17:53:51 +0000 (+0300) Subject: Changed the map creation to create each pixmap just once per round X-Git-Tag: v0.1.0~18 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=2ac7b9142bb6cd8ce4b7af14c12b6bbd2b13bf24;p=ghostsoverboard Changed the map creation to create each pixmap just once per round Just in case creating the pixmap from filename actually reads the file each time, the pixmap is created once per map creation and the same one is given to QGraphicsItem each time its used. --- diff --git a/seascene.cpp b/seascene.cpp index 50a0152..9f59b27 100644 --- a/seascene.cpp +++ b/seascene.cpp @@ -49,7 +49,8 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses) if (pPosition == NULL) break; - QGraphicsPixmapItem * pRock = addPixmap(QPixmap(":/pix/kari.png")); + QPixmap rockPixmap (":/pix/kari.png"); + QGraphicsPixmapItem * pRock = addPixmap(rockPixmap); pRock->setData(0,"rock"); pRock->setPos(*pPosition); delete pPosition; @@ -74,7 +75,8 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses) if (pPosition == NULL) break; - TimerControlledTursas * pOctopus = new TimerControlledTursas (QPixmap(":/pix/tursas.png"),100); + QPixmap octopusPixmap (":/pix/tursas.png"); + TimerControlledTursas * pOctopus = new TimerControlledTursas (octopusPixmap,100); pOctopus->setData(0,"octopus"); pOctopus->setPos(*pPosition); addItem(pOctopus); @@ -116,7 +118,8 @@ void SeaScene::spreadGhosts(int ghosts) if (pPosition == NULL) return; - QGraphicsPixmapItem * pGhost = addPixmap(QPixmap(":/pix/aave.png")); + QPixmap ghostPixmap(":/pix/aave.png"); + QGraphicsPixmapItem * pGhost = addPixmap(ghostPixmap); pGhost->setData(0,"ghost"); pGhost->setPos(*pPosition); delete pPosition;