1

I made a simple 2D game in Qt and deployed it to Android device. Main screen of the game is basically a QGraphicsView. Game world is represented by QGraphicsScene which is larger then the main screen.

I used QGraphicsView::ensureVisible(QGraphicsItem, int, int) to scroll the game world and keep player on screen when he tries to get out of it. Now my game works just fine when the camera is static, but when it tries to follow the player, the performance gets really slow. I think it is especially slow when I have large QGraphicsPixmapItems with transparent areas.

Which optimization options should I use to speed up my app?

Some additional information:

  • All game objects including player are represented by QGraphicsPixmapItems loaded from a *.png with transparent areas.
  • Player's picture is also animated. It loads different pixmap 10 times per second.
  • I call QGraphicsView::ensureVisible(QGraphicsItem, int, int) 30 times per second.
  • I don't set any render hints or optimization options manually.
  • I also did not rewrite paint() and boundingRect() functions of my QGraphicsPixmaps.
  • On PC I don't have this problem.

0 Answers0