Getting started with a Tile-based game in Qt using QGraphicsScene and QGraphicsView

前端 未结 4 980
礼貌的吻别
礼貌的吻别 2021-02-15 15:03

I\'m going to start programming a 2D tile-based game in Qt and read about the QGraphicsScene and QGraphicsView classes which are intended for displaying and handling lots of 2D

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-15 15:24

    QGraphicsScene has the ability to only paint what is being represented in the view, everything else just sits in the the scene index. You have different options for configuring how the scene and view operate to optimize your specific use. Just because you have 40k tiles in your scene index, doesn't mean you need to paint that many. You really only have as many as are being displayed in the resolution of your view.

    Also, there are caching options if your items are static, then they only have to be calculated once and can be retrieved from a pixmap cache.

    Ultimately I think its completely worth your time to try it out. It should be fairly easy for you to mock up a test where you populate your scene with a very large number of tiles and simply try scrolling around the view. I feel its not so much a concern with how many tiles you have, but rather how complex the graphics are within the actual view being painted.

提交回复
热议问题